| 1 |
|
| 2 |
# Test that PL_check hooks for RV2*V can override symbol lookups. |
| 3 |
|
| 4 |
# So far we only test RV2CV. |
| 5 |
|
| 6 |
use XS::APItest; |
| 7 |
use Test::More tests => 4; |
| 8 |
|
| 9 |
BEGIN { |
| 10 |
setup_rv2cv_addunderbar; |
| 11 |
$^H{'XS::APItest/addunder'} = 1; # make foo() actually call foo_() |
| 12 |
} |
| 13 |
|
| 14 |
sub foo_ { @_ ? shift . "___" : "phew" } |
| 15 |
|
| 16 |
is(foo(), "phew"); |
| 17 |
|
| 18 |
# Make sure subs looked up via rv2cv check hooks are not treated as second- |
| 19 |
# class subs. |
| 20 |
|
| 21 |
BEGIN { # If there is a foo symbol, this test will not be testing anything. |
| 22 |
delete $::{foo}; |
| 23 |
delete $::{goo}; |
| 24 |
} |
| 25 |
is((foo bar), 'bar___'); |
| 26 |
$bar = "baz"; |
| 27 |
is((foo $bar), 'baz___'); |
| 28 |
|
| 29 |
# Proto should cause goo() to override Foo->goo interpretation. |
| 30 |
{package Foom} |
| 31 |
sub goo_ (*) { shift . "===" } |
| 32 |
is((goo Foom), "Foom==="); |