3 # This file tests the results of calling subroutines in the CORE::
4 # namespace with ampersand syntax. In other words, it tests the bodies of
5 # the subroutines themselves, not the ops that they might inline themselves
6 # as when called as barewords.
8 # Other tests for CORE subs are in coresubs.t
16 # Since tests inside evals can too easily fail silently, we cannot rely
17 # on done_testing. It’s much easier to count the tests as we go than to
18 # declare the plan up front, so this script ends with a test that makes
19 # sure the right number of tests have happened.
22 &is(map(@$_ ? "[@{[map $_//'~~u~~', @$_]}]" : 'nought', @_[0,1]), $_[2]);
26 use overload '%{}' => sub { +{} }
29 use overload '${}' => sub { \my $x }
33 evalbytes=> 'eval "string"',
34 join => 'join or string',
35 readline => '<HANDLE>',
36 readpipe => 'quoted execution (``, qx)',
37 reset => 'symbol reset',
38 ref => 'reference-type operator',
41 return $op_desc{$_[0]} || $_[0];
45 # This tests that the &{} syntax respects the number of arguments implied
46 # by the prototype, plus some extra tests for the (_) prototype.
50 # Create an alias, for the caller’s convenience.
51 *{"my$o"} = \&{"CORE::$o"};
53 my $p = prototype "CORE::$o";
54 $p = '$;$' if $p eq '$_';
59 eval " &CORE::$o(1) ";
60 like $@, qr/^Too many arguments for $o at /, "&$o with too many args";
66 eval " &CORE::$o(1,2) ";
67 my $desc = quotemeta op_desc($o);
68 like $@, qr/^Too many arguments for $desc at /,
69 "&$o with too many args";
75 my($in,$out) = @_; # for testing implied $_
77 # Since we have $in and $out values, we might as well test basic amper-
80 is &{"CORE::$o"}($in), $out, "&$o";
81 lis [&{"CORE::$o"}($in)], [$out], "&$o in list context";
84 is &{"CORE::$o"}(), $out, "&$o with no args";
86 # Since there is special code to deal with lexical $_, make sure it
91 is &{"CORE::$o"}(), $out, "&$o with no args uses lexical \$_";
93 # Make sure we get the right pad under recursion
98 is &{"CORE::$o"}(), $out,
99 "&$o with no args uses the right lexical \$_ under recursion";
108 is "CORE::$o"->(), $out, "&$o with the right lexical \$_ in an eval"
111 elsif ($p =~ '^;([$*]+)\z') { # ;$ ;* ;$$ etc.
112 my $maxargs = length $1;
114 eval " &CORE::$o((1)x($maxargs+1)) ";
115 my $desc = quotemeta op_desc($o);
116 like $@, qr/^Too many arguments for $desc at /,
117 "&$o with too many args";
119 elsif ($p =~ '^([$*]+);?\z') { # Fixed-length $$$ or ***
120 my $args = length $1;
122 my $desc = quotemeta op_desc($o);
123 eval " &CORE::$o((1)x($args-1)) ";
124 like $@, qr/^Not enough arguments for $desc at /, "&$o w/too few args";
125 eval " &CORE::$o((1)x($args+1)) ";
126 like $@, qr/^Too many arguments for $desc at /, "&$o w/too many args";
128 elsif ($p =~ '^([$*]+);([$*]+)\z') { # Variable-length $$$ or ***
129 my $minargs = length $1;
130 my $maxargs = $minargs + length $2;
132 eval " &CORE::$o((1)x($minargs-1)) ";
133 like $@, qr/^Not enough arguments for $o at /, "&$o with too few args";
134 eval " &CORE::$o((1)x($maxargs+1)) ";
135 like $@, qr/^Too many arguments for $o at /, "&$o with too many args";
137 elsif ($p eq '_;$') {
140 eval " &CORE::$o(1,2,3) ";
141 like $@, qr/^Too many arguments for $o at /, "&$o with too many args";
144 # Do nothing, as we cannot test for too few or too many arguments.
146 elsif ($p =~ '^[$*;]+@\z') {
150 eval " &CORE::$o((1)x($minargs-1)) ";
151 my $desc = quotemeta op_desc($o);
152 like $@, qr/^Not enough arguments for $desc at /,
153 "&$o with too few args";
155 elsif ($p =~ /^\*\\\$\$(;?)\$\z/) { # *\$$$ and *\$$;$
158 eval "&CORE::$o(1,1,1,1,1)";
159 like $@, qr/^Too many arguments for $o at /,
160 "&$o with too many args";
161 eval " &CORE::$o((1)x(\$1?2:3)) ";
162 like $@, qr/^Not enough arguments for $o at /,
163 "&$o with too few args";
164 eval " &CORE::$o(1,[],1,1) ";
165 like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /,
166 "&$o with array ref arg";
167 eval " &CORE::$o(1,1,1,1) ";
168 like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /,
169 "&$o with scalar arg";
170 eval " &CORE::$o(1,bless([], 'sov'),1,1) ";
171 like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /,
172 "&$o with non-scalar arg w/scalar overload (which does not count)";
174 elsif ($p =~ /^\\%\$*\z/) { # \% and \%$$
177 eval "&CORE::$o(" . join(",", (1) x length $p) . ")";
178 like $@, qr/^Too many arguments for $o at /,
179 "&$o with too many args";
180 eval " &CORE::$o(" . join(",", (1) x (length($p)-2)) . ") ";
181 like $@, qr/^Not enough arguments for $o at /,
182 "&$o with too few args";
183 my $moreargs = ",1" x (length($p) - 2);
184 eval " &CORE::$o([]$moreargs) ";
185 like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /,
186 "&$o with array ref arg";
187 eval " &CORE::$o(*foo$moreargs) ";
188 like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /,
189 "&$o with typeglob arg";
190 eval " &CORE::$o(bless([], 'hov')$moreargs) ";
191 like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /,
192 "&$o with non-hash arg with hash overload (which does not count)";
194 elsif ($p =~ /^\\\[(\$\@%&?\*)](\$\@)?\z/) {
199 eval " &CORE::$o(1,2) ";
200 like $@, qr/^Too many arguments for $o at /,
201 "&$o with too many args";
203 eval { &{"CORE::$o"}($2 ? 1 : ()) };
204 like $@, qr/^Not enough arguments for $o at /,
205 "&$o with too few args";
206 my $more_args = $2 ? ',1' : '';
207 eval " &CORE::$o(2$more_args) ";
208 like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x:
210 "&$o with non-ref arg";
211 eval " &CORE::$o(*STDOUT{IO}$more_args) ";
212 like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x:
214 "&$o with ioref arg";
215 my $class = ref *DATA{IO};
216 eval " &CORE::$o(bless(*DATA{IO}, 'hov')$more_args) ";
217 like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x:
219 "&$o with ioref arg with hash overload (which does not count)";
220 bless *DATA{IO}, $class;
221 if (do {$1 !~ /&/}) {
223 eval " &CORE::$o(\\&scriggle$more_args) ";
224 like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one (?x:
226 "&$o with coderef arg";
231 die "Please add tests for the $p prototype";
235 test_proto '__FILE__';
236 test_proto '__LINE__';
237 test_proto '__PACKAGE__';
238 test_proto '__SUB__';
240 is file(), 'frob' , '__FILE__ does check its caller' ; ++ $tests;
241 is line(), 5 , '__LINE__ does check its caller' ; ++ $tests;
242 is pakg(), 'stribble', '__PACKAGE__ does check its caller'; ++ $tests;
243 sub __SUB__test { &my__SUB__ }
244 is __SUB__test, \&__SUB__test, '&__SUB__'; ++ $tests;
246 test_proto 'abs', -5, 5;
250 is &CORE::accept(qw{foo bar}), undef, "&accept";
251 lis [&{"CORE::accept"}(qw{foo bar})], [undef], "&accept in list context";
253 &myaccept(my $foo, my $bar);
254 is ref $foo, 'GLOB', 'CORE::accept autovivifies its first argument';
255 is $bar, undef, 'CORE::accept does not autovivify its second argument';
258 eval { 'myaccept'->($foo, $bar) };
259 like $@, qr/^Can't use an undefined value as a symbol reference at/,
260 'CORE::accept will not accept undef 2nd arg under strict';
261 is ref $foo, 'GLOB', 'CORE::accept autovivs its first arg under strict';
269 is &CORE::bind('foo', 'bear'), undef, "&bind";
270 lis [&CORE::bind('foo', 'bear')], [undef], "&bind in list context";
271 eval { &mybind(my $foo, "bear") };
272 like $@, qr/^Bad symbol for filehandle at/,
273 'CORE::bind dies with undef first arg';
275 test_proto 'binmode';
277 is &CORE::binmode(qw[foo bar]), undef, "&binmode";
278 lis [&CORE::binmode(qw[foo bar])], [undef], "&binmode in list context";
279 is &mybinmode(foo), undef, '&binmode with one arg';
283 like &CORE::bless([],'parcel'), qr/^parcel=ARRAY/, "&bless";
284 like join(" ", &CORE::bless([],'parcel')),
285 qr/^parcel=ARRAY(?!.* )/, "&bless in list context";
286 like &mybless([]), qr/^main=ARRAY/, '&bless with one arg';
297 is $tmp, undef, '&break';
303 is scalar &CORE::caller, 'hadhad', '&caller';
304 is scalar &CORE::caller(1), 'main', '&caller(1)';
305 lis [&CORE::caller], [caller], '&caller in list context';
306 # The last element of caller in list context is a hint hash, which
307 # may be a different hash for caller vs &CORE::caller, so an eq com-
308 # parison (which lis() uses for convenience) won’t work. So just
309 # pop the last element, since the rest are sufficient to prove that
310 # &CORE::caller works.
311 my @ampcaller = &CORE::caller(1);
312 my @caller = caller(1);
313 pop @ampcaller; pop @caller;
314 lis \@ampcaller, \@caller, '&caller(1) in list context';
323 is &CORE::chmod(), 0, '&chmod with no args';
324 is &CORE::chmod(0666), 0, '&chmod';
325 lis [&CORE::chmod(0666)], [0], '&chmod in list context';
329 is &CORE::chown(), 0, '&chown with no args';
330 is &CORE::chown(1), 0, '&chown with 1 arg';
331 is &CORE::chown(1,2), 0, '&chown';
332 lis [&CORE::chown(1,2)], [0], '&chown in list context';
334 test_proto 'chr', 5, "\5";
342 open my $fh, ">", \my $buffalo;
343 print $fh 'an address in the outskirts of Jersey';
344 ok &CORE::close($fh), '&CORE::close retval';
346 is $buffalo, 'an address in the outskirts of Jersey',
347 'effect of &CORE::close';
348 # This has to be a separate variable from $fh, as re-using the same
349 # variable can cause the tests to pass by accident. That actually hap-
350 # pened during developement, because the second close() was reading
351 # beyond the end of the stack and finding a $fh left over from before.
352 open my $fh2, ">", \($buffalo = '');
353 select+(select($fh2), do {
354 print "Nasusiro Tokasoni";
357 is $buffalo, "Nasusiro Tokasoni", '&CORE::close with no args';
360 lis [&CORE::close('tototootot')], [''], '&close in list context'; ++$tests;
362 test_proto 'closedir';
364 is &CORE::closedir(foo), undef, '&CORE::closedir';
365 lis [&CORE::closedir(foo)], [undef], '&CORE::closedir in list context';
367 test_proto 'connect';
369 is &CORE::connect('foo','bar'), undef, '&connect';
370 lis [&myconnect('foo','bar')], [undef], '&connect in list context';
372 test_proto 'continue';
384 test_proto 'dbmclose';
385 test_proto 'dbmopen';
387 last unless eval { require AnyDBM_File };
389 my $filename = tempfile();
390 &mydbmopen(\my %db, $filename, 0666);
391 $db{1} = 2; $db{3} = 4;
393 is scalar keys %db, 0, '&dbmopen and &dbmclose';
397 eval { dier('quinquangle') };
398 is $@, "quinquangle at frob line 6.\n", '&CORE::die'; $tests ++;
400 test_proto $_ for qw(
401 endgrent endhostent endnetent endprotoent endpwent endservent
404 test_proto 'evalbytes';
407 chop(my $upgraded = "use utf8; '\xc4\x80'" . chr 256);
408 is &myevalbytes($upgraded), chr 256, '&evalbytes';
413 is someone, "someone", "run-time hint bits do not leak into &evalbytes"
416 BEGIN { $^H{coreamp} = 42 }
420 is $^H{coreamp}, 42, "compile-time hh propagates into &evalbytes";
424 like $@, qr/strict/, 'compile-time hint bits propagate into &evalbytes';
429 is runperl(prog => '&CORE::exit; END { print qq-ok\n- }'), "ok\n",
430 '&exit with no args';
434 test_proto 'formline';
436 is &myformline(' @<<< @>>>', 1, 2), 1, '&myformline retval';
437 is $^A, ' 1 2', 'effect of &myformline';
438 lis [&myformline('@')], [1], '&myformline in list context';
445 is &CORE::fileno(\*STDIN), fileno STDIN, '&CORE::fileno';
446 lis [&CORE::fileno(\*STDIN)], [fileno STDIN], '&CORE::fileno in list cx';
456 open my $fh, "<", \(my $buf='falo');
457 open STDIN, "<", \(my $buf2 = 'bison');
458 is &mygetc($fh), 'f', '&mygetc';
459 is &mygetc(), 'b', '&mygetc with no args';
460 lis [&mygetc($fh)], ['a'], '&mygetc in list context';
463 test_proto "get$_" for qw '
464 grent grgid grnam hostbyaddr hostbyname hostent login netbyaddr netbyname
468 test_proto 'getpgrp';
470 pass '&getpgrp with no args does not crash'; $tests++;
472 test_proto "get$_" for qw '
473 ppid priority protobyname protobynumber protoent
474 pwent pwnam pwuid servbyname servbyport servent sockname sockopt
479 pass '&gmtime without args does not crash'; ++$tests;
481 test_proto 'hex', ff=>255;
485 is &myindex("foffooo","o",2),4,'&index';
486 lis [&myindex("foffooo","o",2)],[4],'&index in list context';
487 is &myindex("foffooo","o"),1,'&index with 2 args';
489 test_proto 'int', 1.5=>1;
494 is &myjoin('a','b','c'), 'bac', '&join';
495 lis [&myjoin('a','b','c')], ['bac'], '&join in list context';
497 test_proto 'kill'; # set up mykill alias
498 if ($^O ne 'riscos') {
500 ok( &mykill(0, $$), '&kill' );
503 test_proto 'lc', 'A', 'a';
504 test_proto 'lcfirst', 'AA', 'aA';
505 test_proto 'length', 'aaa', 3;
509 test_proto 'localtime';
511 pass '&localtime without args does not crash'; ++$tests;
515 is \&mylock(\$foo), \$foo, '&lock retval when passed a scalar ref';
516 lis [\&mylock(\$foo)], [\$foo], '&lock in list context';
517 is &mylock(\@foo), \@foo, '&lock retval when passed an array ref';
518 is &mylock(\%foo), \%foo, '&lock retval when passed a ash ref';
519 is &mylock(\&foo), \&foo, '&lock retval when passed a code ref';
520 is \&mylock(\*foo), \*foo, '&lock retval when passed a glob ref';
525 # mkdir is tested with implicit $_ at the end, to make the test easier
527 test_proto "msg$_" for qw( ctl get rcv snd );
531 is &mynot(1), !1, '¬';
532 lis [&mynot(0)], [!0], '¬ in list context';
534 test_proto 'oct', '666', 438;
539 ok &myopen('file'), '&open with 1 arg' or warn "1-arg open: $!";
540 like <file>, qr|^#|, 'result of &open with 1 arg';
543 ok &myopen(my $fh, "test.pl"), 'two-arg &open';
544 ok $fh, '&open autovivifies';
545 like <$fh>, qr '^#', 'result of &open with 2 args';
548 ok &myopen(my $fh2, "<", \"sharummbles"), 'retval of 3-arg &open';
549 is <$fh2>, 'sharummbles', 'result of three-arg &open';
552 test_proto 'opendir';
553 test_proto 'ord', chr(64), 64;
557 is &mypack("H*", '5065726c'), 'Perl', '&pack';
558 lis [&mypack("H*", '5065726c')], ['Perl'], '&pack in list context';
561 test_proto 'quotemeta', '$', '\$';
565 like &CORE::rand, qr/^0[.\d]*\z/, '&rand';
566 unlike join(" ", &CORE::rand), qr/ /, '&rand in list context';
567 &cmp_ok(&CORE::rand(78), qw '< 78', '&rand with 2 args');
573 open my $fh, "<", \(my $buff = 'morays have their mores');
574 ok &myread($fh, \my $input, 6), '&read with 3 args';
575 is $input, 'morays', 'value read by 3-arg &read';
576 ok &myread($fh, \$input, 6, 6), '&read with 4 args';
577 is $input, 'morays have ', 'value read by 4-arg &read';
578 is +()=&myread($fh, \$input, 6), 1, '&read in list context';
581 test_proto 'readdir';
583 test_proto 'readline';
587 is scalar &myreadline,
588 "I wandered lonely as a cloud\n", '&readline w/no args';
593 open my $fh, "<", \(my $buff = <<END);
594 The Recursive Problem
595 ---------------------
596 I have a problem I cannot solve.
597 The problem is that I cannot solve it.
599 is &myreadline($fh), "The Recursive Problem\n",
600 '&readline with 1 arg';
601 lis [&myreadline($fh)], [
602 "---------------------\n",
603 "I have a problem I cannot solve.\n",
604 "The problem is that I cannot solve it.\n",
605 ], '&readline in list context';
608 test_proto 'readlink';
609 test_proto 'readpipe';
612 use if !is_miniperl, File::Spec::Functions, qw "catfile";
613 use if !is_miniperl, File::Temp, 'tempdir';
619 my $dir = tempdir(uc cleanup => 1);
620 my $tmpfilenam = catfile $dir, 'aaa';
621 open my $fh, ">", $tmpfilenam or die "cannot open $tmpfilenam: $!";
622 close $fh or die "cannot close $tmpfilenam: $!";
623 &myrename("$tmpfilenam", $tmpfilenam = catfile $dir,'bbb');
624 ok open(my $fh, '>', $tmpfilenam), '&rename';
627 test_proto 'ref', [], 'ARRAY';
631 my $oncer = sub { "a" =~ m?a? };
634 ok &$oncer, '&reset with one arg';
639 ::lis [$b,$banana],[(undef)x2], '2-arg &reset';
642 test_proto 'reverse';
644 is &myreverse('reward'), 'drawer', '&reverse';
645 lis [&myreverse(qw 'dog bites man')], [qw 'man bites dog'],
646 '&reverse in list context';
648 test_proto 'rewinddir';
652 is &myrindex("foffooo","o",2),1,'&rindex';
653 lis [&myrindex("foffooo","o",2)],[1],'&rindex in list context';
654 is &myrindex("foffooo","o"),6,'&rindex with 2 args';
662 open my $fh, "<", \"misled" or die $!;
664 is <$fh>, 'sled', '&seek in action';
667 test_proto 'seekdir';
669 # Can’t test_proto, as it has none
671 *myselect = \&CORE::select;
672 is defined prototype &myselect, defined prototype "CORE::select",
673 'prototype of &select (or lack thereof)';
674 is &myselect, select, '&select with no args';
677 is &myselect(my $fh), $prev, '&select($arg) retval';
678 is lc ref $fh, 'glob', '&select autovivifies';
679 is select=~s/\*//rug, (*$fh."")=~s/\*//rug, '&select selects';
682 eval { &myselect(1,2) };
683 like $@, qr/^Not enough arguments for select system call at /,
684 ,'&myselect($two,$args)';
685 eval { &myselect(1,2,3) };
686 like $@, qr/^Not enough arguments for select system call at /,
687 ,'&myselect($with,$three,$args)';
688 eval { &myselect(1,2,3,4,5) };
689 like $@, qr/^Too many arguments for select system call at /,
690 ,'&myselect($a,$total,$of,$five,$args)';
691 &myselect((undef)x3,.25);
692 # Just have to assume that worked. :-) If we get here, at least it didn’t
695 test_proto "sem$_" for qw "ctl get op";
699 test_proto "set$_" for qw '
703 test_proto 'setpgrp';
705 eval { &mysetpgrp( 0) };
706 pass "&setpgrp with one argument";
708 pass "&setpgrp with no arguments";
710 test_proto "set$_" for qw '
711 priority protoent pwent servent sockopt
714 test_proto "shm$_" for qw "ctl get read write";
715 test_proto 'shutdown';
718 test_proto "socket$_" for "", "pair";
720 test_proto 'sprintf';
722 is &mysprintf("%x", 65), '41', '&sprintf';
723 lis [&mysprintf("%x", '65')], ['41'], '&sprintf in list context';
725 test_proto 'sqrt', 4, 2;
730 pass '&srand with no args does not crash';
735 is &mysubstr($_, 1, 1, "d"), 'b', '4-arg &substr';
736 is $_, 'adc', 'what 4-arg &substr does';
737 is &mysubstr("abc", 1, 1), 'b', '3-arg &substr';
738 is &mysubstr("abc", 1), 'bc', '2-arg &substr';
739 &mysubstr($_, 1) = 'long';
740 is $_, 'along', 'lvalue &substr';
742 test_proto 'symlink';
743 test_proto 'syscall';
745 test_proto 'sysopen';
748 &mysysopen(my $fh, 'test.pl', 0);
749 pass '&sysopen does not crash with 3 args';
750 ok $fh, 'sysopen autovivifies';
753 test_proto 'sysread';
754 test_proto 'sysseek';
755 test_proto 'syswrite';
760 open my $fh, "test.pl" or die "Cannot open test.pl";
762 is &mytell(), tell($fh), '&tell with no args';
763 is &mytell($fh), tell($fh), '&tell with an arg';
766 test_proto 'telldir';
774 sub TIESCALAR { bless[] }
775 sub FETCH { ++$fetches }
778 my $obj = &mytie(\$tied, 'tier');
779 is &mytied(\$tied), $obj, '&tie and &tied retvals';
781 is $fetches, 1, '&tie actually ties';
782 &CORE::untie(\$tied);
784 is $fetches, 1, '&untie unties';
789 like &mytime, '^\d+\z', '&time in scalar context';
790 like join('-', &mytime), '^\d+\z', '&time in list context';
794 like &mytimes, '^[\d.]+\z', '× in scalar context';
795 like join('-',&mytimes), '^[\d.]+-[\d.]+-[\d.]+-[\d.]+\z',
796 '× in list context';
798 test_proto 'uc', 'aa', 'AA';
799 test_proto 'ucfirst', 'aa', "Aa";
803 is &myumask, umask, '&umask with no args';
808 is &myunpack("H*"), '61626364', '&unpack with one arg';
809 is &myunpack("H*", "bcde"), '62636465', '&unpack with two arg';
812 test_proto 'untie'; # behaviour already tested along with tie(d)
816 is &myutime(undef,undef), 0, '&utime';
817 lis [&myutime(undef,undef)], [0], '&utime in list context';
821 is &myvec("foo", 0, 4), 6, '&vec';
822 lis [&myvec("foo", 0, 4)], [6], '&vec in list context';
825 is $tmp, "goo", 'lvalue &vec';
828 test_proto 'waitpid';
830 test_proto 'wantarray';
834 $context = qw[void scalar list][&mywantarray + defined mywantarray()]
837 is $context, 'list', '&wantarray with caller in list context';
839 is($context, 'scalar', '&wantarray with caller in scalar context');
841 is($context, 'void', '&wantarray with caller in void context');
842 lis [&mywantarray],[wantarray], '&wantarray itself in list context';
847 local $SIG{__WARN__} = sub { $w = shift };
848 is &mywarn('a'), 1, '&warn retval';
849 is $w, "a at " . __FILE__ . " line " . (__LINE__-1) . ".\n", 'warning';
850 lis [&mywarn()], [1], '&warn retval in list context';
856 like $@, qr'^Undefined format "STDOUT" called',
857 "&write without arguments can handle the null";
859 # This is just a check to make sure we have tested everything. If we
860 # haven’t, then either the sub needs to be tested or the list in
864 require File::Spec::Functions;
866 File::Spec::Functions::catfile(
867 File::Spec::Functions::updir,'regen','keywords.pl'
869 open my $kh, $keywords_file
870 or die "$0 cannot open $keywords_file: $!";
872 if (m?__END__?..${\0} and /^[-](.*)/) {
875 $word =~ /^(?:CORE|and|cmp|dump|eq|ge|gt|le|lt|ne|or|x|xor)\z/;
877 ok exists &{"my$word"}
878 || (eval{&{"CORE::$word"}}, $@ =~ /cannot be called directly/),
879 "$word either has been tested or is not ampable";
884 # Add new tests above this line.
886 # This test must come last (before the test count test):
894 my $dir = File::Temp::tempdir(uc cleanup => 1);
898 # Make sure that implicit $_ is not applied to mkdir’s second argument.
901 local $SIG{__WARN__} = sub { ++$warnings };
904 ok &mymkdir(), '&mkdir';
905 like <*>, qr/^phoo(.DIR)?\z/i, 'mkdir works with implicit $_';
907 is $warnings, undef, 'no implicit $_ for second argument to mkdir';
909 chdir($cwd); # so auto-cleanup can remove $dir
912 # ------------ END TESTING ----------- #
914 is curr_test, $tests+1, 'right number of tests';
919 sub file { &CORE::__FILE__ }
920 sub line { &CORE::__LINE__ } # 5
921 sub dier { &CORE::die(@_) } # 6
923 sub main::pakg { &CORE::__PACKAGE__ }
925 # Please do not add new tests here.
928 I wandered lonely as a cloud
929 That floats on high o’er vales and hills,
930 And all at once I saw a crowd,
931 A host of golden daffodils!
932 Beside the lake, beneath the trees,
933 Fluttering, dancing, in the breeze.