This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add CVf_CVGV_RC flag
[perl5.git] / ext / Devel-Peek / t / Peek.t
CommitLineData
99331854 1#!./perl -T
9ec58fb7
JH
2
3BEGIN {
9ec58fb7 4 require Config; import Config;
e7ecf62c 5 if ($Config{'extensions'} !~ /\bDevel\/Peek\b/) {
9ec58fb7
JH
6 print "1..0 # Skip: Devel::Peek was not built\n";
7 exit 0;
8 }
9}
10
50a9fad1 11use Test::More tests => 52;
e7ecf62c 12
9248c45a
JH
13use Devel::Peek;
14
9248c45a 15our $DEBUG = 0;
277ddfaf 16open(SAVERR, ">&STDERR") or die "Can't dup STDERR: $!";
9248c45a 17
bfe27a58
NC
18# If I reference any lexicals in this, I get the entire outer subroutine (or
19# MAIN) dumped too, which isn't really what I want, as it's a lot of faff to
20# maintain that.
21format PIE =
22Pie @<<<<<
23$::type
24Good @>>>>>
25$::mmmm
26.
27
9248c45a 28sub do_test {
000fd473
NC
29 my $todo = $_[3];
30 my $repeat_todo = $_[4];
31 my $pattern = $_[2];
277ddfaf
GS
32 if (open(OUT,">peek$$")) {
33 open(STDERR, ">&OUT") or die "Can't dup OUT: $!";
9248c45a 34 Dump($_[1]);
e9569a7a
GG
35 print STDERR "*****\n";
36 Dump($_[1]); # second dump to compare with the first to make sure nothing changed.
277ddfaf
GS
37 open(STDERR, ">&SAVERR") or die "Can't restore STDERR: $!";
38 close(OUT);
9248c45a
JH
39 if (open(IN, "peek$$")) {
40 local $/;
41 $pattern =~ s/\$ADDR/0x[[:xdigit:]]+/g;
8aacddc1 42 $pattern =~ s/\$FLOAT/(?:\\d*\\.\\d+(?:e[-+]\\d+)?|\\d+)/g;
fd0854ff 43 # handle DEBUG_LEAKING_SCALARS prefix
d94a5950 44 $pattern =~ s/^(\s*)(SV =.* at )/(?:$1ALLOCATED at .*?\n)?$1$2/mg;
bf53b3a5 45
000fd473
NC
46 # Need some clear generic mechanism to eliminate (or add) lines
47 # of dump output dependant on perl version. The (previous) use of
48 # things like $IVNV gave the illusion that the string passed in was
49 # a regexp into which variables were interpolated, but this wasn't
50 # actually true as those 'variables' actually also ate the
51 # whitspace on the line. So it seems better to mark lines that
52 # need to be eliminated. I considered (?# ... ) and (?{ ... }),
53 # but whilst embedded code or comment syntax would keep it as a
54 # legitimate regexp, it still isn't true. Seems easier and clearer
55 # things that look like comments.
56
c2485e0c 57 my $version_condition = qr/\$] [<>]=? 5\.\d\d\d/;
000fd473
NC
58 # Could do this is in a s///mge but seems clearer like this:
59 $pattern = join '', map {
60 # If we identify the version condition, take *it* out whatever
c2485e0c 61 s/\s*# ($version_condition(?: && $version_condition)?)$//
000fd473
NC
62 ? (eval $1 ? $_ : '')
63 : $_ # Didn't match, so this line is in
64 } split /^/, $pattern;
65
66 $pattern =~ s/\$PADMY/
67 ($] < 5.009) ? 'PADBUSY,PADMY' : 'PADMY';
68 /mge;
69 $pattern =~ s/\$PADTMP/
70 ($] < 5.009) ? 'PADBUSY,PADTMP' : 'PADTMP';
71 /mge;
2b631c93
NC
72 $pattern =~ s/\$RV/
73 ($] < 5.011) ? 'RV' : 'IV';
74 /mge;
d04ba589 75
9248c45a 76 print $pattern, "\n" if $DEBUG;
e9569a7a 77 my ($dump, $dump2) = split m/\*\*\*\*\*\n/, scalar <IN>;
9248c45a 78 print $dump, "\n" if $DEBUG;
e7ecf62c 79 like( $dump, qr/\A$pattern\Z/ms );
e9569a7a 80
000fd473 81 local $TODO = $repeat_todo;
e9569a7a
GG
82 is($dump2, $dump);
83
9248c45a 84 close(IN);
e9569a7a 85
59d8ce62 86 return $1;
9248c45a
JH
87 } else {
88 die "$0: failed to open peek$$: !\n";
89 }
90 } else {
91 die "$0: failed to create peek$$: $!\n";
92 }
93}
94
95our $a;
96our $b;
97my $c;
208edb77 98local $d = 0;
9248c45a 99
e7ecf62c
RGS
100END {
101 1 while unlink("peek$$");
102}
bf53b3a5 103
9248c45a
JH
104do_test( 1,
105 $a = "foo",
106'SV = PV\\($ADDR\\) at $ADDR
107 REFCNT = 1
108 FLAGS = \\(POK,pPOK\\)
109 PV = $ADDR "foo"\\\0
110 CUR = 3
1badabf5 111 LEN = \\d+'
9248c45a
JH
112 );
113
114do_test( 2,
115 "bar",
116'SV = PV\\($ADDR\\) at $ADDR
117 REFCNT = 1
7766e686 118 FLAGS = \\(.*POK,READONLY,pPOK\\)
9248c45a
JH
119 PV = $ADDR "bar"\\\0
120 CUR = 3
1badabf5 121 LEN = \\d+');
9248c45a
JH
122
123do_test( 3,
124 $b = 123,
125'SV = IV\\($ADDR\\) at $ADDR
126 REFCNT = 1
127 FLAGS = \\(IOK,pIOK\\)
128 IV = 123');
129
130do_test( 4,
131 456,
132'SV = IV\\($ADDR\\) at $ADDR
133 REFCNT = 1
7766e686 134 FLAGS = \\(.*IOK,READONLY,pIOK\\)
9248c45a
JH
135 IV = 456');
136
137do_test( 5,
138 $c = 456,
139'SV = IV\\($ADDR\\) at $ADDR
140 REFCNT = 1
000fd473 141 FLAGS = \\($PADMY,IOK,pIOK\\)
9248c45a
JH
142 IV = 456');
143
59d8ce62
NC
144# If perl is built with PERL_PRESERVE_IVUV then maths is done as integers
145# where possible and this scalar will be an IV. If NO_PERL_PRESERVE_IVUV then
146# maths is done in floating point always, and this scalar will be an NV.
147# ([NI]) captures the type, referred to by \1 in this regexp and $type for
148# building subsequent regexps.
149my $type = do_test( 6,
9248c45a 150 $c + $d,
59d8ce62 151'SV = ([NI])V\\($ADDR\\) at $ADDR
9248c45a 152 REFCNT = 1
59d8ce62
NC
153 FLAGS = \\(PADTMP,\1OK,p\1OK\\)
154 \1V = 456');
9248c45a
JH
155
156($d = "789") += 0.1;
157
158do_test( 7,
159 $d,
160'SV = PVNV\\($ADDR\\) at $ADDR
161 REFCNT = 1
162 FLAGS = \\(NOK,pNOK\\)
78d00c47 163 IV = \d+
ac634a9a 164 NV = 789\\.(?:1(?:000+\d+)?|0999+\d+)
9248c45a
JH
165 PV = $ADDR "789"\\\0
166 CUR = 3
1badabf5 167 LEN = \\d+');
9248c45a
JH
168
169do_test( 8,
170 0xabcd,
171'SV = IV\\($ADDR\\) at $ADDR
172 REFCNT = 1
28e5dec8
JH
173 FLAGS = \\(.*IOK,READONLY,pIOK\\)
174 IV = 43981');
9248c45a
JH
175
176do_test( 9,
177 undef,
178'SV = NULL\\(0x0\\) at $ADDR
179 REFCNT = 1
180 FLAGS = \\(\\)');
181
182do_test(10,
183 \$a,
4df7f6af 184'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
185 REFCNT = 1
186 FLAGS = \\(ROK\\)
187 RV = $ADDR
188 SV = PV\\($ADDR\\) at $ADDR
189 REFCNT = 2
190 FLAGS = \\(POK,pPOK\\)
191 PV = $ADDR "foo"\\\0
192 CUR = 3
1badabf5 193 LEN = \\d+');
9248c45a 194
59d8ce62
NC
195my $c_pattern;
196if ($type eq 'N') {
197 $c_pattern = '
198 SV = PVNV\\($ADDR\\) at $ADDR
199 REFCNT = 1
200 FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
201 IV = 456
202 NV = 456
203 PV = 0';
204} else {
205 $c_pattern = '
206 SV = IV\\($ADDR\\) at $ADDR
207 REFCNT = 1
208 FLAGS = \\(IOK,pIOK\\)
209 IV = 456';
210}
9248c45a
JH
211do_test(11,
212 [$b,$c],
4df7f6af 213'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
214 REFCNT = 1
215 FLAGS = \\(ROK\\)
216 RV = $ADDR
217 SV = PVAV\\($ADDR\\) at $ADDR
78c72037 218 REFCNT = 1
9248c45a 219 FLAGS = \\(\\)
1bcecb77
NC
220 IV = 0 # $] < 5.009
221 NV = 0 # $] < 5.009
9248c45a
JH
222 ARRAY = $ADDR
223 FILL = 1
224 MAX = 1
225 ARYLEN = 0x0
226 FLAGS = \\(REAL\\)
227 Elt No. 0
228 SV = IV\\($ADDR\\) at $ADDR
229 REFCNT = 1
230 FLAGS = \\(IOK,pIOK\\)
231 IV = 123
59d8ce62 232 Elt No. 1' . $c_pattern);
9248c45a
JH
233
234do_test(12,
235 {$b=>$c},
4df7f6af 236'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
237 REFCNT = 1
238 FLAGS = \\(ROK\\)
239 RV = $ADDR
240 SV = PVHV\\($ADDR\\) at $ADDR
78c72037 241 REFCNT = 1
9248c45a 242 FLAGS = \\(SHAREKEYS\\)
1bcecb77
NC
243 IV = 1 # $] < 5.009
244 NV = $FLOAT # $] < 5.009
9248c45a 245 ARRAY = $ADDR \\(0:7, 1:1\\)
b8fa94d8 246 hash quality = 100.0%
9248c45a
JH
247 KEYS = 1
248 FILL = 1
249 MAX = 7
250 RITER = -1
251 EITER = 0x0
000fd473
NC
252 Elt "123" HASH = $ADDR' . $c_pattern,
253 '',
254 $] > 5.009 && 'The hash iterator used in dump.c sets the OOK flag');
9248c45a
JH
255
256do_test(13,
257 sub(){@_},
4df7f6af 258'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
259 REFCNT = 1
260 FLAGS = \\(ROK\\)
261 RV = $ADDR
262 SV = PVCV\\($ADDR\\) at $ADDR
263 REFCNT = 2
cfc1e951 264 FLAGS = \\($PADMY,POK,pPOK,ANON,WEAKOUTSIDE,CVGV_RC\\)
1bcecb77
NC
265 IV = 0 # $] < 5.009
266 NV = 0 # $] < 5.009
9248c45a
JH
267 PROTOTYPE = ""
268 COMP_STASH = $ADDR\\t"main"
269 START = $ADDR ===> \\d+
270 ROOT = $ADDR
1bcecb77
NC
271 XSUB = 0x0 # $] < 5.009
272 XSUBANY = 0 # $] < 5.009
208edb77 273 GVGV::GV = $ADDR\\t"main" :: "__ANON__[^"]*"
084d946d 274 FILE = ".*\\b(?i:peek\\.t)"
000fd473
NC
275 DEPTH = 0(?:
276 MUTEXP = $ADDR
277 OWNER = $ADDR)?
1bcecb77 278 FLAGS = 0x404 # $] < 5.009
cfc1e951 279 FLAGS = 0x490 # $] >= 5.009
a3985cdc 280 OUTSIDE_SEQ = \\d+
9248c45a 281 PADLIST = $ADDR
dd2155a4 282 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
9248c45a
JH
283 OUTSIDE = $ADDR \\(MAIN\\)');
284
285do_test(14,
286 \&do_test,
4df7f6af 287'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
288 REFCNT = 1
289 FLAGS = \\(ROK\\)
290 RV = $ADDR
291 SV = PVCV\\($ADDR\\) at $ADDR
9856a127 292 REFCNT = (3|4)
9248c45a 293 FLAGS = \\(\\)
1bcecb77
NC
294 IV = 0 # $] < 5.009
295 NV = 0 # $] < 5.009
9248c45a
JH
296 COMP_STASH = $ADDR\\t"main"
297 START = $ADDR ===> \\d+
298 ROOT = $ADDR
1bcecb77
NC
299 XSUB = 0x0 # $] < 5.009
300 XSUBANY = 0 # $] < 5.009
9248c45a 301 GVGV::GV = $ADDR\\t"main" :: "do_test"
084d946d 302 FILE = ".*\\b(?i:peek\\.t)"
9248c45a 303 DEPTH = 1
9856a127 304(?: MUTEXP = $ADDR
208edb77
MG
305 OWNER = $ADDR
306)? FLAGS = 0x0
a3985cdc 307 OUTSIDE_SEQ = \\d+
9248c45a 308 PADLIST = $ADDR
dd2155a4 309 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
000fd473
NC
310 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$todo"
311 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$repeat_todo"
ee6cee0c 312 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$pattern"
c2485e0c 313 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$version_condition"
000fd473
NC
314 \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG" # $] < 5.009
315 \\d+\\. $ADDR<\\d+> FAKE "\\$DEBUG" flags=0x0 index=0 # $] >= 5.009
ee6cee0c 316 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump"
e9569a7a 317 \\d+\\. $ADDR<\\d+> \\(\\d+,\\d+\\) "\\$dump2"
9248c45a
JH
318 OUTSIDE = $ADDR \\(MAIN\\)');
319
3ce3ed55
NC
320if ($] >= 5.011) {
321do_test(15,
322 qr(tic),
323'SV = $RV\\($ADDR\\) at $ADDR
324 REFCNT = 1
325 FLAGS = \\(ROK\\)
326 RV = $ADDR
5c35adbb 327 SV = REGEXP\\($ADDR\\) at $ADDR
c2123ae3 328 REFCNT = 1
b9ad13ac 329 FLAGS = \\(OBJECT,POK,FAKE,pPOK\\)
c2123ae3 330 PV = $ADDR "\\(\\?-xism:tic\\)"
f7c278bf 331 CUR = 12
c2123ae3 332 LEN = 0
0fc92fc6 333 STASH = $ADDR\\t"Regexp"');
3ce3ed55 334} else {
9248c45a
JH
335do_test(15,
336 qr(tic),
4df7f6af 337'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
338 REFCNT = 1
339 FLAGS = \\(ROK\\)
340 RV = $ADDR
341 SV = PVMG\\($ADDR\\) at $ADDR
342 REFCNT = 1
faf82a0b 343 FLAGS = \\(OBJECT,SMG\\)
9248c45a
JH
344 IV = 0
345 NV = 0
346 PV = 0
347 MAGIC = $ADDR
348 MG_VIRTUAL = $ADDR
14befaf4 349 MG_TYPE = PERL_MAGIC_qr\(r\)
9248c45a 350 MG_OBJ = $ADDR
1bcecb77
NC
351 PAT = "\(\?-xism:tic\)" # $] >= 5.009
352 REFCNT = 2 # $] >= 5.009
9248c45a 353 STASH = $ADDR\\t"Regexp"');
3ce3ed55 354}
9248c45a
JH
355
356do_test(16,
357 (bless {}, "Tac"),
4df7f6af 358'SV = $RV\\($ADDR\\) at $ADDR
9248c45a
JH
359 REFCNT = 1
360 FLAGS = \\(ROK\\)
361 RV = $ADDR
362 SV = PVHV\\($ADDR\\) at $ADDR
78c72037 363 REFCNT = 1
9248c45a 364 FLAGS = \\(OBJECT,SHAREKEYS\\)
1bcecb77
NC
365 IV = 0 # $] < 5.009
366 NV = 0 # $] < 5.009
9248c45a
JH
367 STASH = $ADDR\\t"Tac"
368 ARRAY = 0x0
369 KEYS = 0
370 FILL = 0
371 MAX = 7
372 RITER = -1
000fd473
NC
373 EITER = 0x0', '',
374 $] > 5.009 ? 'The hash iterator used in dump.c sets the OOK flag'
375 : "Something causes the HV's array to become allocated");
9248c45a
JH
376
377do_test(17,
378 *a,
379'SV = PVGV\\($ADDR\\) at $ADDR
380 REFCNT = 5
000fd473
NC
381 FLAGS = \\(MULTI(?:,IN_PAD)?\\) # $] >= 5.009
382 FLAGS = \\(GMG,SMG,MULTI(?:,IN_PAD)?\\) # $] < 5.009
383 IV = 0 # $] < 5.009
384 NV = 0 # $] < 5.009
385 PV = 0 # $] < 5.009
386 MAGIC = $ADDR # $] < 5.009
387 MG_VIRTUAL = &PL_vtbl_glob # $] < 5.009
388 MG_TYPE = PERL_MAGIC_glob\(\*\) # $] < 5.009
389 MG_OBJ = $ADDR # $] < 5.009
9248c45a
JH
390 NAME = "a"
391 NAMELEN = 1
392 GvSTASH = $ADDR\\t"main"
393 GP = $ADDR
394 SV = $ADDR
395 REFCNT = 1
396 IO = 0x0
397 FORM = 0x0
398 AV = 0x0
399 HV = 0x0
400 CV = 0x0
401 CVGEN = 0x0
000fd473 402 GPFLAGS = 0x0 # $] < 5.009
9ec58fb7 403 LINE = \\d+
084d946d 404 FILE = ".*\\b(?i:peek\\.t)"
e39917cc 405 FLAGS = $ADDR
9248c45a
JH
406 EGV = $ADDR\\t"a"');
407
cdb2dd7b
JH
408if (ord('A') == 193) {
409do_test(18,
410 chr(256).chr(0).chr(512),
411'SV = PV\\($ADDR\\) at $ADDR
412 REFCNT = 1
000fd473 413 FLAGS = \\((?:$PADTMP,)?POK,READONLY,pPOK,UTF8\\)
cdb2dd7b
JH
414 PV = $ADDR "\\\214\\\101\\\0\\\235\\\101"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
415 CUR = 5
1badabf5 416 LEN = \\d+');
cdb2dd7b 417} else {
e6abe6d8
JH
418do_test(18,
419 chr(256).chr(0).chr(512),
420'SV = PV\\($ADDR\\) at $ADDR
421 REFCNT = 1
000fd473 422 FLAGS = \\((?:$PADTMP,)?POK,READONLY,pPOK,UTF8\\)
98c991d1 423 PV = $ADDR "\\\304\\\200\\\0\\\310\\\200"\\\0 \[UTF8 "\\\x\{100\}\\\x\{0\}\\\x\{200\}"\]
e6abe6d8 424 CUR = 5
1badabf5 425 LEN = \\d+');
cdb2dd7b 426}
e6abe6d8 427
cdb2dd7b
JH
428if (ord('A') == 193) {
429do_test(19,
430 {chr(256)=>chr(512)},
4df7f6af 431'SV = $RV\\($ADDR\\) at $ADDR
cdb2dd7b
JH
432 REFCNT = 1
433 FLAGS = \\(ROK\\)
434 RV = $ADDR
435 SV = PVHV\\($ADDR\\) at $ADDR
78c72037 436 REFCNT = 1
b2caaddd 437 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
1bcecb77
NC
438 UV = 1 # $] < 5.009
439 NV = $FLOAT # $] < 5.009
cdb2dd7b
JH
440 ARRAY = $ADDR \\(0:7, 1:1\\)
441 hash quality = 100.0%
442 KEYS = 1
443 FILL = 1
444 MAX = 7
445 RITER = -1
446 EITER = $ADDR
6cbfa5b4 447 Elt "\\\214\\\101" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
cdb2dd7b
JH
448 SV = PV\\($ADDR\\) at $ADDR
449 REFCNT = 1
450 FLAGS = \\(POK,pPOK,UTF8\\)
451 PV = $ADDR "\\\235\\\101"\\\0 \[UTF8 "\\\x\{200\}"\]
452 CUR = 2
000fd473
NC
453 LEN = \\d+',
454 $] > 5.009 ? 'The hash iterator used in dump.c sets the OOK flag'
455 : 'sv_length has been called on the element, and cached the result in MAGIC');
cdb2dd7b 456} else {
98c991d1
JH
457do_test(19,
458 {chr(256)=>chr(512)},
4df7f6af 459'SV = $RV\\($ADDR\\) at $ADDR
98c991d1
JH
460 REFCNT = 1
461 FLAGS = \\(ROK\\)
462 RV = $ADDR
463 SV = PVHV\\($ADDR\\) at $ADDR
78c72037 464 REFCNT = 1
19692e8d 465 FLAGS = \\(SHAREKEYS,HASKFLAGS\\)
1bcecb77
NC
466 UV = 1 # $] < 5.009
467 NV = 0 # $] < 5.009
98c991d1
JH
468 ARRAY = $ADDR \\(0:7, 1:1\\)
469 hash quality = 100.0%
470 KEYS = 1
471 FILL = 1
472 MAX = 7
473 RITER = -1
474 EITER = $ADDR
475 Elt "\\\304\\\200" \[UTF8 "\\\x\{100\}"\] HASH = $ADDR
476 SV = PV\\($ADDR\\) at $ADDR
477 REFCNT = 1
478 FLAGS = \\(POK,pPOK,UTF8\\)
479 PV = $ADDR "\\\310\\\200"\\\0 \[UTF8 "\\\x\{200\}"\]
480 CUR = 2
000fd473
NC
481 LEN = \\d+', '',
482 $] > 5.009 ? 'The hash iterator used in dump.c sets the OOK flag'
483 : 'sv_length has been called on the element, and cached the result in MAGIC');
cdb2dd7b 484}
98c991d1 485
99331854
YST
486my $x="";
487$x=~/.??/g;
488do_test(20,
489 $x,
490'SV = PVMG\\($ADDR\\) at $ADDR
491 REFCNT = 1
000fd473 492 FLAGS = \\($PADMY,SMG,POK,pPOK\\)
99331854
YST
493 IV = 0
494 NV = 0
495 PV = $ADDR ""\\\0
496 CUR = 0
1936d2a7 497 LEN = \d+
99331854
YST
498 MAGIC = $ADDR
499 MG_VIRTUAL = &PL_vtbl_mglob
500 MG_TYPE = PERL_MAGIC_regex_global\\(g\\)
501 MG_FLAGS = 0x01
502 MINMATCH');
503
f24fdb76
HS
504#
505# TAINTEDDIR is not set on: OS2, AMIGAOS, WIN32, MSDOS
506# environment variables may be invisibly case-forced, hence the (?i:PATH)
5e836f43 507# C<scalar(@ARGV)> is turned into an IV on VMS hence the (?:IV)?
d9baf692
JM
508# VMS is setting FAKE and READONLY flags. What VMS uses for storing
509# ENV hashes is also not always null terminated.
f24fdb76 510#
99331854
YST
511do_test(21,
512 $ENV{PATH}=@ARGV, # scalar(@ARGV) is a handy known tainted value
513'SV = PVMG\\($ADDR\\) at $ADDR
514 REFCNT = 1
515 FLAGS = \\(GMG,SMG,RMG,pIOK,pPOK\\)
516 IV = 0
517 NV = 0
518 PV = $ADDR "0"\\\0
519 CUR = 1
520 LEN = \d+
521 MAGIC = $ADDR
522 MG_VIRTUAL = &PL_vtbl_envelem
523 MG_TYPE = PERL_MAGIC_envelem\\(e\\)
d25a523c 524(?: MG_FLAGS = 0x01
99331854 525 TAINTEDDIR
143a3e5e
CB
526)? MG_LEN = -?\d+
527 MG_PTR = $ADDR (?:"(?i:PATH)"|=> HEf_SVKEY
5e836f43 528 SV = PV(?:IV)?\\($ADDR\\) at $ADDR
143a3e5e 529 REFCNT = \d+
11e2783c 530 FLAGS = \\(TEMP,POK,(?:FAKE,READONLY,)?pPOK\\)
f0fabfd7 531(?: IV = 0
d9baf692 532)? PV = $ADDR "(?i:PATH)"(?:\\\0)?
143a3e5e
CB
533 CUR = \d+
534 LEN = \d+)
99331854
YST
535 MAGIC = $ADDR
536 MG_VIRTUAL = &PL_vtbl_taint
537 MG_TYPE = PERL_MAGIC_taint\\(t\\)');
538
6bf47b08
SR
539# blessed refs
540do_test(22,
541 bless(\\undef, 'Foobar'),
4df7f6af 542'SV = $RV\\($ADDR\\) at $ADDR
6bf47b08
SR
543 REFCNT = 1
544 FLAGS = \\(ROK\\)
545 RV = $ADDR
546 SV = PVMG\\($ADDR\\) at $ADDR
547 REFCNT = 2
548 FLAGS = \\(OBJECT,ROK\\)
7957ad98
MB
549 IV = -?\d+
550 NV = $FLOAT
6bf47b08
SR
551 RV = $ADDR
552 SV = NULL\\(0x0\\) at $ADDR
553 REFCNT = \d+
554 FLAGS = \\(READONLY\\)
555 PV = $ADDR ""
556 CUR = 0
557 LEN = 0
558 STASH = $ADDR\s+"Foobar"');
b1886099
NC
559
560# Constant subroutines
561
562sub const () {
563 "Perl rules";
564}
565
566do_test(23,
567 \&const,
4df7f6af 568'SV = $RV\\($ADDR\\) at $ADDR
b1886099
NC
569 REFCNT = 1
570 FLAGS = \\(ROK\\)
571 RV = $ADDR
572 SV = PVCV\\($ADDR\\) at $ADDR
573 REFCNT = (2)
574 FLAGS = \\(POK,pPOK,CONST\\)
1bcecb77
NC
575 IV = 0 # $] < 5.009
576 NV = 0 # $] < 5.009
b1886099
NC
577 PROTOTYPE = ""
578 COMP_STASH = 0x0
1bcecb77 579 ROOT = 0x0 # $] < 5.009
b1886099
NC
580 XSUB = $ADDR
581 XSUBANY = $ADDR \\(CONST SV\\)
582 SV = PV\\($ADDR\\) at $ADDR
583 REFCNT = 1
584 FLAGS = \\(.*POK,READONLY,pPOK\\)
585 PV = $ADDR "Perl rules"\\\0
586 CUR = 10
587 LEN = \\d+
588 GVGV::GV = $ADDR\\t"main" :: "const"
589 FILE = ".*\\b(?i:peek\\.t)"
000fd473
NC
590 DEPTH = 0(?:
591 MUTEXP = $ADDR
592 OWNER = $ADDR)?
1bcecb77 593 FLAGS = 0x200 # $] < 5.009
c2485e0c
NC
594 FLAGS = 0xc00 # $] >= 5.009 && $] < 5.013
595 FLAGS = 0xc # $] >= 5.013
b1886099
NC
596 OUTSIDE_SEQ = 0
597 PADLIST = 0x0
598 OUTSIDE = 0x0 \\(null\\)');
2e94196c
NC
599
600# isUV should show on PVMG
601do_test(24,
602 do { my $v = $1; $v = ~0; $v },
603'SV = PVMG\\($ADDR\\) at $ADDR
604 REFCNT = 1
605 FLAGS = \\(IOK,pIOK,IsUV\\)
606 UV = \d+
607 NV = 0
608 PV = 0');
c0a413d1
NC
609
610do_test(25,
611 *STDOUT{IO},
612'SV = $RV\\($ADDR\\) at $ADDR
613 REFCNT = 1
614 FLAGS = \\(ROK\\)
615 RV = $ADDR
616 SV = PVIO\\($ADDR\\) at $ADDR
617 REFCNT = 3
618 FLAGS = \\(OBJECT\\)
3cf51070 619 IV = 0 # $] < 5.011
1bcecb77 620 NV = 0 # $] < 5.011
d963bf01 621 STASH = $ADDR\s+"IO::File"
c0a413d1
NC
622 IFP = $ADDR
623 OFP = $ADDR
624 DIRP = 0x0
625 LINES = 0
626 PAGE = 0
627 PAGE_LEN = 60
628 LINES_LEFT = 0
629 TOP_GV = 0x0
630 FMT_GV = 0x0
631 BOTTOM_GV = 0x0
1bcecb77 632 SUBPROCESS = 0 # $] < 5.009
c0a413d1 633 TYPE = \'>\'
50a9fad1 634 FLAGS = 0x4');
bfe27a58
NC
635
636do_test(26,
637 *PIE{FORMAT},
638'SV = $RV\\($ADDR\\) at $ADDR
639 REFCNT = 1
640 FLAGS = \\(ROK\\)
641 RV = $ADDR
642 SV = PVFM\\($ADDR\\) at $ADDR
643 REFCNT = 2
644 FLAGS = \\(\\)
30ec677d 645 IV = 0 # $] < 5.009
bfe27a58 646 NV = 0 # $] < 5.009
251a4af1
DM
647(?: PV = 0
648)? COMP_STASH = 0x0
bfe27a58
NC
649 START = $ADDR ===> \\d+
650 ROOT = $ADDR
651 XSUB = 0x0 # $] < 5.009
652 XSUBANY = 0 # $] < 5.009
653 GVGV::GV = $ADDR\\t"main" :: "PIE"
654 FILE = ".*\\b(?i:peek\\.t)"
c12100a4
DM
655(?: DEPTH = 0
656 MUTEXP = $ADDR
bfe27a58
NC
657 OWNER = $ADDR
658)? FLAGS = 0x0
659 OUTSIDE_SEQ = \\d+
660 LINES = 0
661 PADLIST = $ADDR
662 PADNAME = $ADDR\\($ADDR\\) PAD = $ADDR\\($ADDR\\)
663 OUTSIDE = $ADDR \\(MAIN\\)');