File: sym-hook.t

package info (click to toggle)
perl 5.42.0-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (32 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# Test that PL_check hooks for RV2*V can override symbol lookups.

# So far we only test RV2CV.

use XS::APItest;
use Test::More tests => 4;

BEGIN {
    setup_rv2cv_addunderbar;
    $^H{'XS::APItest/addunder'} = 1; # make foo() actually call foo_()
}

sub foo_ { @_ ? shift . "___" : "phew" }

is(foo(), "phew");

# Make sure subs looked up via rv2cv check hooks are not treated as second-
# class subs.

BEGIN { # If there is a foo symbol, this test will not be testing anything.
    delete $::{foo};
    delete $::{goo};
}
is((foo bar), 'bar___');
$bar = "baz";
is((foo $bar), 'baz___');

# Proto should cause goo() to override Foo->goo interpretation.
{package Foom}
sub goo_ (*) { shift . "===" }
is((goo Foom), "Foom===");