44#
55# Initially this test file just checked that CORE::foo got correctly
66# deparsed as CORE::foo, hence the name. It's since been expanded
7- # to fully test both CORE:: verses none, plus that any arguments
7+ # to fully test both CORE:: versus none, plus that any arguments
88# are correctly deparsed. It also cross-checks against regen/keywords.pl
99# to make sure we've tested all keywords, and with the correct strength.
1010#
@@ -36,11 +36,10 @@ BEGIN {
3636
3737use strict;
3838use Test::More;
39- plan tests => 4006 ;
39+ plan tests => 3886 ;
4040
4141use feature (sprintf (" :%vd " , $^V)); # to avoid relying on the feature
4242 # logic to add CORE::
43- no warnings ' experimental::autoderef' ;
4443use B::Deparse;
4544my $deparse = new B::Deparse;
4645
@@ -81,35 +80,35 @@ sub testit {
8180 $desc .= " (lex sub)" if $lexsub ;
8281
8382
84- my $ code_ref ;
83+ my ( $code , $ code_ref) ;
8584 if ($lexsub ) {
8685 package lexsubtest ;
8786 no warnings ' experimental::lexical_subs' ;
8887 use feature ' lexical_subs' ;
8988 no strict ' vars' ;
90- $code_ref =
91- eval " sub { state sub $keyword ; ${vars} () = $expr }"
92- || die " $@ in $expr " ;
89+ $code = " sub { state sub $keyword ; ${vars} () = $expr }" ;
90+ $code_ref = eval $code || die " $@ in $expr " ;
9391 }
9492 else {
9593 package test ;
9694 use subs ();
9795 import subs $keyword ;
98- $code_ref = eval " no strict 'vars'; sub { ${vars} () = $expr }"
99- or die " $@ in $expr " ;
96+ $code = " no strict 'vars'; sub { ${vars} () = $expr }" ;
97+ $code_ref = eval $code || die " $@ in $expr " ;
10098 }
10199
102100 my $got_text = $deparse -> coderef2text($code_ref );
103101
104102 unless ($got_text =~ /
105103 package (?:lexsub)?test;
106- BEGIN \{\$\{\^ WARNING_BITS} = "[^"]*"}
107104 use strict 'refs', 'subs';
108105 use feature [^\n ]+
109106 \Q $vars \E\(\) = (.*)
110107}/s ) {
111108 ::fail($desc );
112109 ::diag(" couldn't extract line from boilerplate\n " );
110+ ::diag($code );
111+ ::diag(" =>" );
113112 ::diag($got_text );
114113 return ;
115114 }
@@ -252,6 +251,7 @@ testit do => 'do { 1 };',
252251 " do {\n 1\n };" ;
253252
254253testit each => ' CORE::each %bar;' ;
254+ testit each => ' CORE::each @foo;' ;
255255
256256testit eof => ' CORE::eof();' ;
257257
@@ -271,17 +271,32 @@ testit glob => 'CORE::glob $a;', 'CORE::glob($a);';
271271testit grep => ' CORE::grep { $a } $b, $c' , ' grep({$a;} $b, $c);' ;
272272
273273testit keys => ' CORE::keys %bar;' ;
274+ testit keys => ' CORE::keys @bar;' ;
274275
275276testit map => ' CORE::map { $a } $b, $c' , ' map({$a;} $b, $c);' ;
276277
277278testit not => ' 3 unless CORE::not $a && $b;' ;
278279
280+ testit pop => ' CORE::pop @foo;' ;
281+
282+ testit push => ' CORE::push @foo;' , ' CORE::push(@foo);' ;
283+ testit push => ' CORE::push @foo, 1;' , ' CORE::push(@foo, 1);' ;
284+ testit push => ' CORE::push @foo, 1, 2;' , ' CORE::push(@foo, 1, 2);' ;
285+
279286testit readline => ' CORE::readline $a . $b;' ;
280287
281288testit readpipe => ' CORE::readpipe $a + $b;' ;
282289
283290testit reverse => ' CORE::reverse sort(@foo);' ;
284291
292+ testit shift => ' CORE::shift @foo;' ;
293+
294+ testit splice => q{ CORE::splice @foo;} , q{ CORE::splice(@foo);} ;
295+ testit splice => q{ CORE::splice @foo, 0;} , q{ CORE::splice(@foo, 0);} ;
296+ testit splice => q{ CORE::splice @foo, 0, 1;} , q{ CORE::splice(@foo, 0, 1);} ;
297+ testit splice => q{ CORE::splice @foo, 0, 1, 'a';} , q{ CORE::splice(@foo, 0, 1, 'a');} ;
298+ testit splice => q{ CORE::splice @foo, 0, 1, 'a', 'b';} , q{ CORE::splice(@foo, 0, 1, 'a', 'b');} ;
299+
285300# note that the test does '() = split...' which is why the
286301# limit is optimised to 1
287302testit split => ' split;' , q{ split(' ', $_, 1);} ;
@@ -298,7 +313,12 @@ testit sub => 'CORE::sub { $a, $b }',
298313
299314testit system => ' CORE::system($foo $bar);' ;
300315
316+ testit unshift => ' CORE::unshift @foo;' , ' CORE::unshift(@foo);' ;
317+ testit unshift => ' CORE::unshift @foo, 1;' , ' CORE::unshift(@foo, 1);' ;
318+ testit unshift => ' CORE::unshift @foo, 1, 2;' , ' CORE::unshift(@foo, 1, 2);' ;
319+
301320testit values => ' CORE::values %bar;' ;
321+ testit values => ' CORE::values @foo;' ;
302322
303323
304324# XXX These are deparsed wrapped in parens.
@@ -463,7 +483,7 @@ defined 01 $+
463483die @ p1
464484# do handled specially
465485# dump handled specially
466- each 1 - # also tested specially
486+ # each handled specially
467487endgrent 0 -
468488endhostent 0 -
469489endnetent 0 -
@@ -522,7 +542,7 @@ index 23 p
522542int 01 $
523543ioctl 3 p
524544join 13 p
525- keys 1 - # also tested specially
545+ # keys handled specially
526546kill 123 p
527547# last handled specially
528548lc 01 $
@@ -555,12 +575,12 @@ ord 01 $
555575our 123 p+ # skip with 0 args, as our() => ()
556576pack 123 p
557577pipe 2 p
558- pop 01 1
578+ pop 0 1 # also tested specially
559579pos 01 $+
560580print @ p$+
561581printf @ p$+
562582prototype 1 +
563- push 123 p
583+ # push handled specially
564584quotemeta 01 $
565585rand 01 -
566586read 34 p
@@ -601,7 +621,7 @@ setprotoent 1 -
601621setpwent 0 -
602622setservent 1 -
603623setsockopt 4 p
604- shift 01 1
624+ shift 0 1 # also tested specially
605625shmctl 3 p
606626shmget 3 p
607627shmread 4 p
@@ -613,7 +633,7 @@ socket 4 p
613633socketpair 5 p
614634sort @ p1+
615635# split handled specially
616- splice 12345 p
636+ # splice handled specially
617637sprintf 123 p
618638sqrt 01 $
619639srand 01 -
@@ -642,10 +662,10 @@ umask 01 -
642662undef 01 +
643663unlink @ p$
644664unpack 12 p$
645- unshift 1 p
665+ # unshift handled specially
646666untie 1 -
647667utime @ p1
648- values 1 - # also tested specially
668+ # values handled specially
649669vec 3 p
650670wait 0 -
651671waitpid 2 p
0 commit comments