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