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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
################################################################################
#
# !!!!! Do NOT edit this file directly! !!!!!
#
# Edit mktests.PL and/or parts/inc/cop instead.
#
# This file was automatically generated from the definition files in the
# parts/inc/ subdirectory by mktests.PL. To learn more about how all this
# works, please read the F<HACKERS> file that came with this distribution.
#
################################################################################
BEGIN {
if ($ENV{'PERL_CORE'}) {
chdir 't' if -d 't';
@INC = ('../lib', '../ext/Devel-PPPort/t') if -d '../lib' && -d '../ext';
require Config; import Config;
use vars '%Config';
if (" $Config{'extensions'} " !~ m[ Devel/PPPort ]) {
print "1..0 # Skip -- Perl configured without Devel::PPPort module\n";
exit 0;
}
}
else {
unshift @INC, 't';
}
sub load {
eval "use Test";
require 'testutil.pl' if $@;
}
if (28) {
load();
plan(tests => 28);
}
}
use Devel::PPPort;
use strict;
$^W = 1;
package Devel::PPPort;
use vars '@ISA';
require DynaLoader;
@ISA = qw(DynaLoader);
bootstrap Devel::PPPort;
package main;
my $package;
{
package MyPackage;
$package = &Devel::PPPort::CopSTASHPV();
}
print "# $package\n";
ok($package, "MyPackage");
my $file = &Devel::PPPort::CopFILE();
print "# $file\n";
ok($file =~ /cop/i);
BEGIN {
if ($] < 5.006000) {
# Skip
for (1..28) {
ok(1, 1);
}
exit;
}
}
BEGIN {
package DB;
no strict "refs";
local $^P = 1;
sub sub { &$DB::sub }
}
{ package One; sub one { Devel::PPPort::caller_cx($_[0]) } }
{
package Two;
sub two { One::one(@_) }
sub dbtwo {
BEGIN { $^P = 1 }
One::one(@_);
BEGIN { $^P = 0 }
}
}
for (
# This is rather confusing. The package is the package the call is
# made *from*, the sub name is the sub the call is made *to*. When
# DB::sub is involved the first call is to DB::sub from the calling
# package, the second is to the real sub from package DB.
[\&One::one, 0, qw/main one main one/],
[\&One::one, 2, ],
[\&Two::two, 0, qw/Two one Two one/],
[\&Two::two, 1, qw/main two main two/],
[\&Two::dbtwo, 0, qw/Two sub DB one/],
[\&Two::dbtwo, 1, qw/main dbtwo main dbtwo/],
) {
my ($sub, $arg, @want) = @$_;
my @got = $sub->($arg);
ok(@got, @want);
for (0..$#want) {
ok($got[$_], $want[$_]);
}
}
|