File: test60-subname.p

package info (click to toggle)
libdevel-nytprof-perl 6.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,888 kB
  • sloc: perl: 5,497; javascript: 4,033; ansic: 107; makefile: 27
file content (35 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (7)
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
33
34
35
# test sub name resolution
use Devel::NYTProf::Test qw(example_xsub);

# call XS sub directly
Devel::NYTProf::Test::example_xsub("foo");

# call XS sub imported into main
# (should still be reported as a call to Devel::NYTProf::Test::example_xsub)
example_xsub("foo");

# call XS sub as a method (ignore the extra arg)
Devel::NYTProf::Test->example_xsub();

# call XS sub as a method via subclass (ignore the extra arg)
@Subclass::ISA = qw(Devel::NYTProf::Test);
Subclass->example_xsub();

my $subname = "Devel::NYTProf::Test::example_xsub";
&$subname("foo");

# return from xsub call via an exception
# should correctly record the name of the xsub
sub will_die { die "foo\n" }
eval { example_xsub(0, \&will_die); 1; };
warn "\$@ was not the expected 'foo': $@" if $@ ne "foo\n";

# goto &$sub
sub launch { goto &$subname }
launch("foo");

# call builtin
wait();

# call builtin that exits via an exception
eval { open my $f, '<&', 'nonesuch' }; # $@ "Bad filehandle: nonesuch"