1898184e3Ssthen#!./perl 2898184e3Ssthen 3898184e3Ssthen# This file tests the results of calling subroutines in the CORE:: 4898184e3Ssthen# namespace with ampersand syntax. In other words, it tests the bodies of 5898184e3Ssthen# the subroutines themselves, not the ops that they might inline themselves 6898184e3Ssthen# as when called as barewords. 7898184e3Ssthen 8898184e3Ssthen# Other tests for CORE subs are in coresubs.t 9898184e3Ssthen 10898184e3SsthenBEGIN { 11898184e3Ssthen chdir 't' if -d 't'; 12eac174f2Safresh1 require "./test.pl"; 139f11ffb7Safresh1 set_up_inc( qw(. ../lib ../dist/if) ); 14eac174f2Safresh1 require './charset_tools.pl'; 15eac174f2Safresh1 $^P |= 0x100; # Provide informative "file" names for evals 16898184e3Ssthen} 17898184e3Ssthen 18898184e3Ssthensub lis($$;$) { 19898184e3Ssthen &is(map(@$_ ? "[@{[map $_//'~~u~~', @$_]}]" : 'nought', @_[0,1]), $_[2]); 20898184e3Ssthen} 21898184e3Ssthen 22898184e3Ssthenpackage hov { 23898184e3Ssthen use overload '%{}' => sub { +{} } 24898184e3Ssthen} 259f11ffb7Safresh1package aov { 269f11ffb7Safresh1 use overload '@{}' => sub { [] } 279f11ffb7Safresh1} 28898184e3Ssthenpackage sov { 29898184e3Ssthen use overload '${}' => sub { \my $x } 30898184e3Ssthen} 31898184e3Ssthen 32898184e3Ssthenmy %op_desc = ( 33898184e3Ssthen evalbytes => 'eval "string"', 34898184e3Ssthen join => 'join or string', 3591f110e0Safresh1 pos => 'match position', 3691f110e0Safresh1 prototype => 'subroutine prototype', 37898184e3Ssthen readline => '<HANDLE>', 38898184e3Ssthen readpipe => 'quoted execution (``, qx)', 39898184e3Ssthen reset => 'symbol reset', 40898184e3Ssthen ref => 'reference-type operator', 4191f110e0Safresh1 undef => 'undef operator', 42898184e3Ssthen); 43898184e3Ssthensub op_desc($) { 44898184e3Ssthen return $op_desc{$_[0]} || $_[0]; 45898184e3Ssthen} 46898184e3Ssthen 47898184e3Ssthen 48898184e3Ssthen# This tests that the &{} syntax respects the number of arguments implied 49898184e3Ssthen# by the prototype, plus some extra tests for the (_) prototype. 50898184e3Ssthensub test_proto { 51898184e3Ssthen my($o) = shift; 52898184e3Ssthen 53898184e3Ssthen # Create an alias, for the caller’s convenience. 54898184e3Ssthen *{"my$o"} = \&{"CORE::$o"}; 55898184e3Ssthen 56898184e3Ssthen my $p = prototype "CORE::$o"; 57898184e3Ssthen $p = '$;$' if $p eq '$_'; 58898184e3Ssthen 59898184e3Ssthen if ($p eq '') { 60898184e3Ssthen $tests ++; 61898184e3Ssthen 62898184e3Ssthen eval " &CORE::$o(1) "; 63898184e3Ssthen like $@, qr/^Too many arguments for $o at /, "&$o with too many args"; 64898184e3Ssthen 65898184e3Ssthen } 6691f110e0Safresh1 elsif ($p =~ /^_;?\z/) { 67898184e3Ssthen $tests ++; 68898184e3Ssthen 69898184e3Ssthen eval " &CORE::$o(1,2) "; 70898184e3Ssthen my $desc = quotemeta op_desc($o); 71898184e3Ssthen like $@, qr/^Too many arguments for $desc at /, 72898184e3Ssthen "&$o with too many args"; 73898184e3Ssthen 74898184e3Ssthen if (!@_) { return } 75898184e3Ssthen 76b8851fccSafresh1 $tests += 3; 77898184e3Ssthen 78898184e3Ssthen my($in,$out) = @_; # for testing implied $_ 79898184e3Ssthen 80898184e3Ssthen # Since we have $in and $out values, we might as well test basic amper- 81898184e3Ssthen # sand calls, too. 82898184e3Ssthen 83898184e3Ssthen is &{"CORE::$o"}($in), $out, "&$o"; 84898184e3Ssthen lis [&{"CORE::$o"}($in)], [$out], "&$o in list context"; 85898184e3Ssthen 86898184e3Ssthen $_ = $in; 87898184e3Ssthen is &{"CORE::$o"}(), $out, "&$o with no args"; 88898184e3Ssthen } 89898184e3Ssthen elsif ($p =~ '^;([$*]+)\z') { # ;$ ;* ;$$ etc. 90898184e3Ssthen my $maxargs = length $1; 91898184e3Ssthen $tests += 1; 92898184e3Ssthen eval " &CORE::$o((1)x($maxargs+1)) "; 93898184e3Ssthen my $desc = quotemeta op_desc($o); 94898184e3Ssthen like $@, qr/^Too many arguments for $desc at /, 95898184e3Ssthen "&$o with too many args"; 96898184e3Ssthen } 97898184e3Ssthen elsif ($p =~ '^([$*]+);?\z') { # Fixed-length $$$ or *** 98898184e3Ssthen my $args = length $1; 99898184e3Ssthen $tests += 2; 100898184e3Ssthen my $desc = quotemeta op_desc($o); 101898184e3Ssthen eval " &CORE::$o((1)x($args-1)) "; 102898184e3Ssthen like $@, qr/^Not enough arguments for $desc at /, "&$o w/too few args"; 103898184e3Ssthen eval " &CORE::$o((1)x($args+1)) "; 104898184e3Ssthen like $@, qr/^Too many arguments for $desc at /, "&$o w/too many args"; 105898184e3Ssthen } 106898184e3Ssthen elsif ($p =~ '^([$*]+);([$*]+)\z') { # Variable-length $$$ or *** 107898184e3Ssthen my $minargs = length $1; 108898184e3Ssthen my $maxargs = $minargs + length $2; 109898184e3Ssthen $tests += 2; 110898184e3Ssthen eval " &CORE::$o((1)x($minargs-1)) "; 111898184e3Ssthen like $@, qr/^Not enough arguments for $o at /, "&$o with too few args"; 112898184e3Ssthen eval " &CORE::$o((1)x($maxargs+1)) "; 113898184e3Ssthen like $@, qr/^Too many arguments for $o at /, "&$o with too many args"; 114898184e3Ssthen } 115898184e3Ssthen elsif ($p eq '_;$') { 116898184e3Ssthen $tests += 1; 117898184e3Ssthen 118898184e3Ssthen eval " &CORE::$o(1,2,3) "; 119898184e3Ssthen like $@, qr/^Too many arguments for $o at /, "&$o with too many args"; 120898184e3Ssthen } 121898184e3Ssthen elsif ($p eq '@') { 122898184e3Ssthen # Do nothing, as we cannot test for too few or too many arguments. 123898184e3Ssthen } 124898184e3Ssthen elsif ($p =~ '^[$*;]+@\z') { 125898184e3Ssthen $tests ++; 126898184e3Ssthen $p =~ ';@'; 127898184e3Ssthen my $minargs = $-[0]; 128898184e3Ssthen eval " &CORE::$o((1)x($minargs-1)) "; 129898184e3Ssthen my $desc = quotemeta op_desc($o); 130898184e3Ssthen like $@, qr/^Not enough arguments for $desc at /, 131898184e3Ssthen "&$o with too few args"; 132898184e3Ssthen } 133898184e3Ssthen elsif ($p =~ /^\*\\\$\$(;?)\$\z/) { # *\$$$ and *\$$;$ 134898184e3Ssthen $tests += 5; 135898184e3Ssthen 136898184e3Ssthen eval "&CORE::$o(1,1,1,1,1)"; 137898184e3Ssthen like $@, qr/^Too many arguments for $o at /, 138898184e3Ssthen "&$o with too many args"; 139898184e3Ssthen eval " &CORE::$o((1)x(\$1?2:3)) "; 140898184e3Ssthen like $@, qr/^Not enough arguments for $o at /, 141898184e3Ssthen "&$o with too few args"; 142898184e3Ssthen eval " &CORE::$o(1,[],1,1) "; 143898184e3Ssthen like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /, 144898184e3Ssthen "&$o with array ref arg"; 145898184e3Ssthen eval " &CORE::$o(1,1,1,1) "; 146898184e3Ssthen like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /, 147898184e3Ssthen "&$o with scalar arg"; 148898184e3Ssthen eval " &CORE::$o(1,bless([], 'sov'),1,1) "; 149898184e3Ssthen like $@, qr/^Type of arg 2 to &CORE::$o must be scalar reference at /, 150898184e3Ssthen "&$o with non-scalar arg w/scalar overload (which does not count)"; 151898184e3Ssthen } 152898184e3Ssthen elsif ($p =~ /^\\%\$*\z/) { # \% and \%$$ 153898184e3Ssthen $tests += 5; 154898184e3Ssthen 155898184e3Ssthen eval "&CORE::$o(" . join(",", (1) x length $p) . ")"; 156898184e3Ssthen like $@, qr/^Too many arguments for $o at /, 157898184e3Ssthen "&$o with too many args"; 158898184e3Ssthen eval " &CORE::$o(" . join(",", (1) x (length($p)-2)) . ") "; 159898184e3Ssthen like $@, qr/^Not enough arguments for $o at /, 160898184e3Ssthen "&$o with too few args"; 161898184e3Ssthen my $moreargs = ",1" x (length($p) - 2); 162898184e3Ssthen eval " &CORE::$o([]$moreargs) "; 163898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /, 164898184e3Ssthen "&$o with array ref arg"; 165898184e3Ssthen eval " &CORE::$o(*foo$moreargs) "; 166898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /, 167898184e3Ssthen "&$o with typeglob arg"; 168898184e3Ssthen eval " &CORE::$o(bless([], 'hov')$moreargs) "; 169898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be hash reference at /, 170898184e3Ssthen "&$o with non-hash arg with hash overload (which does not count)"; 171898184e3Ssthen } 17291f110e0Safresh1 elsif ($p =~ /^(;)?\\\[(\$\@%&?\*)](\$\@)?\z/) { 17391f110e0Safresh1 $tests += 3; 174898184e3Ssthen 17591f110e0Safresh1 unless ($3) { 176898184e3Ssthen $tests ++; 177898184e3Ssthen eval " &CORE::$o(1,2) "; 17891f110e0Safresh1 like $@, qr/^Too many arguments for ${\op_desc($o)} at /, 179898184e3Ssthen "&$o with too many args"; 180898184e3Ssthen } 18191f110e0Safresh1 unless ($1) { 18291f110e0Safresh1 $tests ++; 18391f110e0Safresh1 eval { &{"CORE::$o"}($3 ? 1 : ()) }; 184898184e3Ssthen like $@, qr/^Not enough arguments for $o at /, 185898184e3Ssthen "&$o with too few args"; 18691f110e0Safresh1 } 18791f110e0Safresh1 my $more_args = $3 ? ',1' : ''; 188898184e3Ssthen eval " &CORE::$o(2$more_args) "; 189898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x: 1909f11ffb7Safresh1 ) \[\Q$2\E\] at /, 191898184e3Ssthen "&$o with non-ref arg"; 192898184e3Ssthen eval " &CORE::$o(*STDOUT{IO}$more_args) "; 193898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x: 1949f11ffb7Safresh1 ) \[\Q$2\E\] at /, 195898184e3Ssthen "&$o with ioref arg"; 196898184e3Ssthen my $class = ref *DATA{IO}; 197898184e3Ssthen eval " &CORE::$o(bless(*DATA{IO}, 'hov')$more_args) "; 198898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one of(?x: 1999f11ffb7Safresh1 ) \[\Q$2\E\] at /, 200898184e3Ssthen "&$o with ioref arg with hash overload (which does not count)"; 201898184e3Ssthen bless *DATA{IO}, $class; 20291f110e0Safresh1 if (do {$2 !~ /&/}) { 203898184e3Ssthen $tests++; 204898184e3Ssthen eval " &CORE::$o(\\&scriggle$more_args) "; 205898184e3Ssthen like $@, qr/^Type of arg 1 to &CORE::$o must be reference to one (?x: 2069f11ffb7Safresh1 )of \[\Q$2\E\] at /, 207898184e3Ssthen "&$o with coderef arg"; 208898184e3Ssthen } 209898184e3Ssthen } 2109f11ffb7Safresh1 elsif ($p =~ /^;?\\\@([\@;])?/) { # ;\@ \@@ \@;$$@ 2119f11ffb7Safresh1 $tests += 7; 2129f11ffb7Safresh1 2139f11ffb7Safresh1 if ($1) { 2149f11ffb7Safresh1 eval { &{"CORE::$o"}() }; 2159f11ffb7Safresh1 like $@, qr/^Not enough arguments for $o at /, 2169f11ffb7Safresh1 "&$o with too few args"; 2179f11ffb7Safresh1 } 2189f11ffb7Safresh1 else { 2199f11ffb7Safresh1 eval " &CORE::$o(\\\@1,2) "; 2209f11ffb7Safresh1 like $@, qr/^Too many arguments for $o at /, 2219f11ffb7Safresh1 "&$o with too many args"; 2229f11ffb7Safresh1 } 2239f11ffb7Safresh1 eval " &CORE::$o(2) "; 2249f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2259f11ffb7Safresh1 "&$o with non-ref arg"; 2269f11ffb7Safresh1 eval " &CORE::$o(*STDOUT{IO}) "; 2279f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2289f11ffb7Safresh1 "&$o with ioref arg"; 2299f11ffb7Safresh1 my $class = ref *DATA{IO}; 2309f11ffb7Safresh1 eval " &CORE::$o(bless(*DATA{IO}, 'aov')) "; 2319f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2329f11ffb7Safresh1 "&$o with ioref arg with array overload (which does not count)"; 2339f11ffb7Safresh1 bless *DATA{IO}, $class; 2349f11ffb7Safresh1 eval " &CORE::$o(\\&scriggle) "; 2359f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2369f11ffb7Safresh1 "&$o with coderef arg"; 2379f11ffb7Safresh1 eval " &CORE::$o(\\\$_) "; 2389f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2399f11ffb7Safresh1 "&$o with scalarref arg"; 2409f11ffb7Safresh1 eval " &CORE::$o({}) "; 2419f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be array reference at /, 2429f11ffb7Safresh1 "&$o with hashref arg"; 2439f11ffb7Safresh1 } 2449f11ffb7Safresh1 elsif ($p eq '\[%@]') { 2459f11ffb7Safresh1 $tests += 7; 2469f11ffb7Safresh1 2479f11ffb7Safresh1 eval " &CORE::$o(\\%1,2) "; 2489f11ffb7Safresh1 like $@, qr/^Too many arguments for ${\op_desc($o)} at /, 2499f11ffb7Safresh1 "&$o with too many args"; 2509f11ffb7Safresh1 eval { &{"CORE::$o"}() }; 2519f11ffb7Safresh1 like $@, qr/^Not enough arguments for $o at /, 2529f11ffb7Safresh1 "&$o with too few args"; 2539f11ffb7Safresh1 eval " &CORE::$o(2) "; 2549f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be hash or array (?x: 2559f11ffb7Safresh1 )reference at /, 2569f11ffb7Safresh1 "&$o with non-ref arg"; 2579f11ffb7Safresh1 eval " &CORE::$o(*STDOUT{IO}) "; 2589f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be hash or array (?x: 2599f11ffb7Safresh1 )reference at /, 2609f11ffb7Safresh1 "&$o with ioref arg"; 2619f11ffb7Safresh1 my $class = ref *DATA{IO}; 2629f11ffb7Safresh1 eval " &CORE::$o(bless(*DATA{IO}, 'hov')) "; 2639f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be hash or array (?x: 2649f11ffb7Safresh1 )reference at /, 2659f11ffb7Safresh1 "&$o with ioref arg with hash overload (which does not count)"; 2669f11ffb7Safresh1 bless *DATA{IO}, $class; 2679f11ffb7Safresh1 eval " &CORE::$o(\\&scriggle) "; 2689f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be hash or array (?x: 2699f11ffb7Safresh1 )reference at /, 2709f11ffb7Safresh1 "&$o with coderef arg"; 2719f11ffb7Safresh1 eval " &CORE::$o(\\\$_) "; 2729f11ffb7Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be hash or array (?x: 2739f11ffb7Safresh1 )reference at /, 2749f11ffb7Safresh1 "&$o with scalarref arg"; 2759f11ffb7Safresh1 } 27691f110e0Safresh1 elsif ($p eq ';\[$*]') { 27791f110e0Safresh1 $tests += 4; 27891f110e0Safresh1 27991f110e0Safresh1 my $desc = quotemeta op_desc($o); 28091f110e0Safresh1 eval " &CORE::$o(1,2) "; 28191f110e0Safresh1 like $@, qr/^Too many arguments for $desc at /, 28291f110e0Safresh1 "&$o with too many args"; 28391f110e0Safresh1 eval " &CORE::$o([]) "; 28491f110e0Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be scalar reference at /, 28591f110e0Safresh1 "&$o with array ref arg"; 28691f110e0Safresh1 eval " &CORE::$o(1) "; 28791f110e0Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be scalar reference at /, 28891f110e0Safresh1 "&$o with scalar arg"; 28991f110e0Safresh1 eval " &CORE::$o(bless([], 'sov')) "; 29091f110e0Safresh1 like $@, qr/^Type of arg 1 to &CORE::$o must be scalar reference at /, 29191f110e0Safresh1 "&$o with non-scalar arg w/scalar overload (which does not count)"; 29291f110e0Safresh1 } 293898184e3Ssthen 294898184e3Ssthen else { 295898184e3Ssthen die "Please add tests for the $p prototype"; 296898184e3Ssthen } 297898184e3Ssthen} 298898184e3Ssthen 29991f110e0Safresh1# Test that &CORE::foo calls without parentheses (no new @_) can handle the 30091f110e0Safresh1# total absence of any @_ without crashing. 30191f110e0Safresh1undef *_; 30291f110e0Safresh1&CORE::wantarray; 30391f110e0Safresh1$tests++; 30491f110e0Safresh1pass('no crash with &CORE::foo when *_{ARRAY} is undef'); 30591f110e0Safresh1 306*3d61058aSafresh1test_proto '__CLASS__'; 307898184e3Ssthentest_proto '__FILE__'; 308898184e3Ssthentest_proto '__LINE__'; 309898184e3Ssthentest_proto '__PACKAGE__'; 310898184e3Ssthentest_proto '__SUB__'; 311898184e3Ssthen 312898184e3Ssthenis file(), 'frob' , '__FILE__ does check its caller' ; ++ $tests; 313898184e3Ssthenis line(), 5 , '__LINE__ does check its caller' ; ++ $tests; 314898184e3Ssthenis pakg(), 'stribble', '__PACKAGE__ does check its caller'; ++ $tests; 315898184e3Ssthensub __SUB__test { &my__SUB__ } 316898184e3Ssthenis __SUB__test, \&__SUB__test, '&__SUB__'; ++ $tests; 317898184e3Ssthen 318898184e3Ssthentest_proto 'abs', -5, 5; 319898184e3Ssthen 320b8851fccSafresh1SKIP: 321b8851fccSafresh1{ 322b8851fccSafresh1 if ($^O eq "MSWin32" && is_miniperl) { 323b8851fccSafresh1 $tests += 8; 324b8851fccSafresh1 skip "accept() not available in Win32 miniperl", 8 325b8851fccSafresh1 } 326b8851fccSafresh1 $tests += 6; 327898184e3Ssthen test_proto 'accept'; 328b8851fccSafresh1 eval q{ 329898184e3Ssthen is &CORE::accept(qw{foo bar}), undef, "&accept"; 330898184e3Ssthen lis [&{"CORE::accept"}(qw{foo bar})], [undef], "&accept in list context"; 331898184e3Ssthen 332898184e3Ssthen &myaccept(my $foo, my $bar); 333898184e3Ssthen is ref $foo, 'GLOB', 'CORE::accept autovivifies its first argument'; 334898184e3Ssthen is $bar, undef, 'CORE::accept does not autovivify its second argument'; 335898184e3Ssthen use strict; 336898184e3Ssthen undef $foo; 337898184e3Ssthen eval { 'myaccept'->($foo, $bar) }; 338898184e3Ssthen like $@, qr/^Can't use an undefined value as a symbol reference at/, 339898184e3Ssthen 'CORE::accept will not accept undef 2nd arg under strict'; 340898184e3Ssthen is ref $foo, 'GLOB', 'CORE::accept autovivs its first arg under strict'; 341898184e3Ssthen }; 342b8851fccSafresh1} 343898184e3Ssthen 344898184e3Ssthentest_proto 'alarm'; 345898184e3Ssthentest_proto 'atan2'; 346898184e3Ssthen 347898184e3Ssthentest_proto 'bind'; 348898184e3Ssthen$tests += 3; 349b8851fccSafresh1SKIP: 350b8851fccSafresh1{ 351b8851fccSafresh1 skip "bind() not available in Win32 miniperl", 3 352b8851fccSafresh1 if $^O eq "MSWin32" && is_miniperl(); 353898184e3Ssthen is &CORE::bind('foo', 'bear'), undef, "&bind"; 354898184e3Ssthen lis [&CORE::bind('foo', 'bear')], [undef], "&bind in list context"; 355898184e3Ssthen eval { &mybind(my $foo, "bear") }; 356898184e3Ssthen like $@, qr/^Bad symbol for filehandle at/, 357898184e3Ssthen 'CORE::bind dies with undef first arg'; 358b8851fccSafresh1} 359898184e3Ssthen 360898184e3Ssthentest_proto 'binmode'; 361898184e3Ssthen$tests += 3; 362898184e3Ssthenis &CORE::binmode(qw[foo bar]), undef, "&binmode"; 363898184e3Ssthenlis [&CORE::binmode(qw[foo bar])], [undef], "&binmode in list context"; 364898184e3Ssthenis &mybinmode(foo), undef, '&binmode with one arg'; 365898184e3Ssthen 366898184e3Ssthentest_proto 'bless'; 367898184e3Ssthen$tests += 3; 368898184e3Ssthenlike &CORE::bless([],'parcel'), qr/^parcel=ARRAY/, "&bless"; 369eac174f2Safresh1like join(" ", &CORE::bless([],'parcel')), qr/^parcel=ARRAY(?!.* )/, 370eac174f2Safresh1 "&bless in list context"; 371898184e3Ssthenlike &mybless([]), qr/^main=ARRAY/, '&bless with one arg'; 372898184e3Ssthen 373898184e3Ssthentest_proto 'break'; 374eac174f2Safresh1{ 375eac174f2Safresh1 $tests ++; 376898184e3Ssthen my $tmp; 377e0680481Safresh1 no warnings 'deprecated'; 378898184e3Ssthen CORE::given(1) { 379898184e3Ssthen CORE::when(1) { 380898184e3Ssthen &mybreak; 381898184e3Ssthen $tmp = 'bad'; 382898184e3Ssthen } 383898184e3Ssthen } 384898184e3Ssthen is $tmp, undef, '&break'; 385898184e3Ssthen} 386898184e3Ssthen 387898184e3Ssthentest_proto 'caller'; 388898184e3Ssthen$tests += 4; 389898184e3Ssthensub caller_test { 390898184e3Ssthen is scalar &CORE::caller, 'hadhad', '&caller'; 391898184e3Ssthen is scalar &CORE::caller(1), 'main', '&caller(1)'; 392898184e3Ssthen lis [&CORE::caller], [caller], '&caller in list context'; 393898184e3Ssthen # The last element of caller in list context is a hint hash, which 394898184e3Ssthen # may be a different hash for caller vs &CORE::caller, so an eq com- 395898184e3Ssthen # parison (which lis() uses for convenience) won’t work. So just 396898184e3Ssthen # pop the last element, since the rest are sufficient to prove that 397898184e3Ssthen # &CORE::caller works. 398898184e3Ssthen my @ampcaller = &CORE::caller(1); 399898184e3Ssthen my @caller = caller(1); 400898184e3Ssthen pop @ampcaller; pop @caller; 401898184e3Ssthen lis \@ampcaller, \@caller, '&caller(1) in list context'; 402898184e3Ssthen} 403898184e3Ssthensub { 404898184e3Ssthen package hadhad; 405898184e3Ssthen ::caller_test(); 406898184e3Ssthen}->(); 407898184e3Ssthen 408898184e3Ssthentest_proto 'chmod'; 409898184e3Ssthen$tests += 3; 410898184e3Ssthenis &CORE::chmod(), 0, '&chmod with no args'; 411898184e3Ssthenis &CORE::chmod(0666), 0, '&chmod'; 412898184e3Ssthenlis [&CORE::chmod(0666)], [0], '&chmod in list context'; 413898184e3Ssthen 414898184e3Ssthentest_proto 'chown'; 415898184e3Ssthen$tests += 4; 416898184e3Ssthenis &CORE::chown(), 0, '&chown with no args'; 417898184e3Ssthenis &CORE::chown(1), 0, '&chown with 1 arg'; 418898184e3Ssthenis &CORE::chown(1,2), 0, '&chown'; 419898184e3Ssthenlis [&CORE::chown(1,2)], [0], '&chown in list context'; 420898184e3Ssthen 421898184e3Ssthentest_proto 'chr', 5, "\5"; 422898184e3Ssthentest_proto 'chroot'; 423898184e3Ssthen 424898184e3Ssthentest_proto 'close'; 425898184e3Ssthen{ 426898184e3Ssthen last if is_miniperl; 427898184e3Ssthen $tests += 3; 428898184e3Ssthen 429898184e3Ssthen open my $fh, ">", \my $buffalo; 430898184e3Ssthen print $fh 'an address in the outskirts of Jersey'; 431898184e3Ssthen ok &CORE::close($fh), '&CORE::close retval'; 432898184e3Ssthen print $fh 'lalala'; 433898184e3Ssthen is $buffalo, 'an address in the outskirts of Jersey', 434898184e3Ssthen 'effect of &CORE::close'; 435898184e3Ssthen # This has to be a separate variable from $fh, as re-using the same 436898184e3Ssthen # variable can cause the tests to pass by accident. That actually hap- 437898184e3Ssthen # pened during developement, because the second close() was reading 438898184e3Ssthen # beyond the end of the stack and finding a $fh left over from before. 439898184e3Ssthen open my $fh2, ">", \($buffalo = ''); 440898184e3Ssthen select+(select($fh2), do { 441898184e3Ssthen print "Nasusiro Tokasoni"; 442898184e3Ssthen &CORE::close(); 443898184e3Ssthen print "jfd"; 444898184e3Ssthen is $buffalo, "Nasusiro Tokasoni", '&CORE::close with no args'; 445898184e3Ssthen })[0]; 446898184e3Ssthen} 447898184e3Ssthenlis [&CORE::close('tototootot')], [''], '&close in list context'; ++$tests; 448898184e3Ssthen 449898184e3Ssthentest_proto 'closedir'; 450898184e3Ssthen$tests += 2; 451898184e3Ssthenis &CORE::closedir(foo), undef, '&CORE::closedir'; 452898184e3Ssthenlis [&CORE::closedir(foo)], [undef], '&CORE::closedir in list context'; 453898184e3Ssthen 454898184e3Ssthentest_proto 'connect'; 455898184e3Ssthen$tests += 2; 456b8851fccSafresh1SKIP: 457b8851fccSafresh1{ 458b8851fccSafresh1 skip "connect() not available in Win32 miniperl", 2 459b8851fccSafresh1 if $^O eq "MSWin32" && is_miniperl(); 460898184e3Ssthen is &CORE::connect('foo','bar'), undef, '&connect'; 461898184e3Ssthen lis [&myconnect('foo','bar')], [undef], '&connect in list context'; 462b8851fccSafresh1} 463898184e3Ssthen 464898184e3Ssthentest_proto 'continue'; 465898184e3Ssthen$tests ++; 466e0680481Safresh1no warnings 'deprecated'; 467898184e3SsthenCORE::given(1) { 468898184e3Ssthen CORE::when(1) { 469898184e3Ssthen &mycontinue(); 470898184e3Ssthen } 471898184e3Ssthen pass "&continue"; 472898184e3Ssthen} 473898184e3Ssthen 474898184e3Ssthentest_proto 'cos'; 475898184e3Ssthentest_proto 'crypt'; 476898184e3Ssthen 477898184e3Ssthentest_proto 'dbmclose'; 478898184e3Ssthentest_proto 'dbmopen'; 479898184e3Ssthen{ 480898184e3Ssthen last unless eval { require AnyDBM_File }; 481898184e3Ssthen $tests ++; 482898184e3Ssthen my $filename = tempfile(); 483898184e3Ssthen &mydbmopen(\my %db, $filename, 0666); 484898184e3Ssthen $db{1} = 2; $db{3} = 4; 485898184e3Ssthen &mydbmclose(\%db); 486898184e3Ssthen is scalar keys %db, 0, '&dbmopen and &dbmclose'; 4876fb12b70Safresh1 my $Dfile = "$filename.pag"; 4886fb12b70Safresh1 if (! -e $Dfile) { 4896fb12b70Safresh1 ($Dfile) = <$filename*>; 4906fb12b70Safresh1 } 4916fb12b70Safresh1 if ($^O eq 'VMS') { 4926fb12b70Safresh1 unlink "$filename.sdbm_dir", $Dfile; 4936fb12b70Safresh1 } else { 4946fb12b70Safresh1 unlink "$filename.dir", $Dfile; 4956fb12b70Safresh1 } 496898184e3Ssthen} 497898184e3Ssthen 498898184e3Ssthentest_proto 'die'; 499898184e3Sstheneval { dier('quinquangle') }; 500898184e3Ssthenis $@, "quinquangle at frob line 6.\n", '&CORE::die'; $tests ++; 501898184e3Ssthen 502898184e3Ssthentest_proto $_ for qw( 503898184e3Ssthen endgrent endhostent endnetent endprotoent endpwent endservent 504898184e3Ssthen); 505898184e3Ssthen 506898184e3Ssthentest_proto 'evalbytes'; 507898184e3Ssthen$tests += 4; 508898184e3Ssthen{ 509b8851fccSafresh1 my $U_100_bytes = byte_utf8a_to_utf8n("\xc4\x80"); 510b8851fccSafresh1 chop(my $upgraded = "use utf8; $U_100_bytes" . chr 256); 511898184e3Ssthen is &myevalbytes($upgraded), chr 256, '&evalbytes'; 512898184e3Ssthen # Test hints 513898184e3Ssthen require strict; 514898184e3Ssthen strict->import; 515898184e3Ssthen &myevalbytes(' 516898184e3Ssthen is someone, "someone", "run-time hint bits do not leak into &evalbytes" 517898184e3Ssthen '); 518898184e3Ssthen use strict; 519898184e3Ssthen BEGIN { $^H{coreamp} = 42 } 520898184e3Ssthen $^H{coreamp} = 75; 521898184e3Ssthen &myevalbytes(' 522898184e3Ssthen BEGIN { 523898184e3Ssthen is $^H{coreamp}, 42, "compile-time hh propagates into &evalbytes"; 524898184e3Ssthen } 525898184e3Ssthen ${"frobnicate"} 526898184e3Ssthen '); 527898184e3Ssthen like $@, qr/strict/, 'compile-time hint bits propagate into &evalbytes'; 528898184e3Ssthen} 529898184e3Ssthen 530898184e3Ssthentest_proto 'exit'; 531898184e3Ssthen$tests ++; 532898184e3Ssthenis runperl(prog => '&CORE::exit; END { print qq-ok\n- }'), "ok\n", 533898184e3Ssthen '&exit with no args'; 534898184e3Ssthen 535898184e3Ssthentest_proto 'fork'; 536898184e3Ssthen 537898184e3Ssthentest_proto 'formline'; 538898184e3Ssthen$tests += 3; 539898184e3Ssthenis &myformline(' @<<< @>>>', 1, 2), 1, '&myformline retval'; 540898184e3Ssthenis $^A, ' 1 2', 'effect of &myformline'; 541898184e3Ssthenlis [&myformline('@')], [1], '&myformline in list context'; 542898184e3Ssthen 5439f11ffb7Safresh1test_proto 'each'; 5449f11ffb7Safresh1$tests += 4; 5459f11ffb7Safresh1is &myeach({ "a","b" }), "a", '&myeach(\%hash) in scalar cx'; 5469f11ffb7Safresh1lis [&myeach({qw<a b>})], [qw<a b>], '&myeach(\%hash) in list cx'; 5479f11ffb7Safresh1is &myeach([ "a","b" ]), 0, '&myeach(\@array) in scalar cx'; 5489f11ffb7Safresh1lis [&myeach([qw<a b>])], [qw<0 a>], '&myeach(\@array) in list cx'; 5499f11ffb7Safresh1 550898184e3Ssthentest_proto 'exp'; 551898184e3Ssthen 552898184e3Ssthentest_proto 'fc'; 553898184e3Ssthen$tests += 2; 554898184e3Ssthen{ 555b8851fccSafresh1 my $sharp_s = uni_to_native("\xdf"); 556898184e3Ssthen is &myfc($sharp_s), $sharp_s, '&fc, no unicode_strings'; 557898184e3Ssthen use feature 'unicode_strings'; 558898184e3Ssthen is &myfc($sharp_s), "ss", '&fc, unicode_strings'; 559898184e3Ssthen} 560898184e3Ssthen 561898184e3Ssthentest_proto 'fcntl'; 562898184e3Ssthen 563898184e3Ssthentest_proto 'fileno'; 564898184e3Ssthen$tests += 2; 565898184e3Ssthenis &CORE::fileno(\*STDIN), fileno STDIN, '&CORE::fileno'; 566898184e3Ssthenlis [&CORE::fileno(\*STDIN)], [fileno STDIN], '&CORE::fileno in list cx'; 567898184e3Ssthen 568898184e3Ssthentest_proto 'flock'; 569898184e3Ssthentest_proto 'fork'; 570898184e3Ssthen 571898184e3Ssthentest_proto 'getc'; 572898184e3Ssthen{ 573898184e3Ssthen last if is_miniperl; 574898184e3Ssthen $tests += 3; 575898184e3Ssthen local *STDIN; 576898184e3Ssthen open my $fh, "<", \(my $buf='falo'); 577898184e3Ssthen open STDIN, "<", \(my $buf2 = 'bison'); 578898184e3Ssthen is &mygetc($fh), 'f', '&mygetc'; 579898184e3Ssthen is &mygetc(), 'b', '&mygetc with no args'; 580898184e3Ssthen lis [&mygetc($fh)], ['a'], '&mygetc in list context'; 581898184e3Ssthen} 582898184e3Ssthen 583898184e3Ssthentest_proto "get$_" for qw ' 584898184e3Ssthen grent grgid grnam hostbyaddr hostbyname hostent login netbyaddr netbyname 585898184e3Ssthen netent peername 586898184e3Ssthen'; 587898184e3Ssthen 588898184e3Ssthentest_proto 'getpgrp'; 589898184e3Sstheneval {&mygetpgrp()}; 590898184e3Ssthenpass '&getpgrp with no args does not crash'; $tests++; 591898184e3Ssthen 592898184e3Ssthentest_proto "get$_" for qw ' 593898184e3Ssthen ppid priority protobyname protobynumber protoent 594898184e3Ssthen pwent pwnam pwuid servbyname servbyport servent sockname sockopt 595898184e3Ssthen'; 596898184e3Ssthen 59791f110e0Safresh1# Make sure the following tests test what we think they are testing. 59891f110e0Safresh1ok ! $CORE::{glob}, '*CORE::glob not autovivified yet'; $tests ++; 59991f110e0Safresh1{ 60091f110e0Safresh1 # Make sure ck_glob does not respect the override when &CORE::glob is 60191f110e0Safresh1 # autovivified (by test_proto). 60291f110e0Safresh1 local *CORE::GLOBAL::glob = sub {}; 60391f110e0Safresh1 test_proto 'glob'; 60491f110e0Safresh1} 60591f110e0Safresh1$_ = "t/*.t"; 60691f110e0Safresh1@_ = &myglob($_); 60791f110e0Safresh1is join($", &myglob()), "@_", '&glob without arguments'; 60891f110e0Safresh1is join($", &myglob("t/*.t")), "@_", '&glob with an arg'; 60991f110e0Safresh1$tests += 2; 61091f110e0Safresh1 611898184e3Ssthentest_proto 'gmtime'; 612898184e3Ssthen&CORE::gmtime; 613898184e3Ssthenpass '&gmtime without args does not crash'; ++$tests; 614898184e3Ssthen 615898184e3Ssthentest_proto 'hex', ff=>255; 616898184e3Ssthen 617898184e3Ssthentest_proto 'index'; 618898184e3Ssthen$tests += 3; 619898184e3Ssthenis &myindex("foffooo","o",2),4,'&index'; 620898184e3Ssthenlis [&myindex("foffooo","o",2)],[4],'&index in list context'; 621898184e3Ssthenis &myindex("foffooo","o"),1,'&index with 2 args'; 622898184e3Ssthen 623898184e3Ssthentest_proto 'int', 1.5=>1; 624898184e3Ssthentest_proto 'ioctl'; 625898184e3Ssthen 626898184e3Ssthentest_proto 'join'; 627898184e3Ssthen$tests += 2; 628898184e3Ssthenis &myjoin('a','b','c'), 'bac', '&join'; 629898184e3Ssthenlis [&myjoin('a','b','c')], ['bac'], '&join in list context'; 630898184e3Ssthen 6319f11ffb7Safresh1test_proto 'keys'; 6329f11ffb7Safresh1$tests += 6; 6339f11ffb7Safresh1is &mykeys({ 1..4 }), 2, '&mykeys(\%hash) in scalar cx'; 6349f11ffb7Safresh1lis [sort &mykeys({1..4})], [1,3], '&mykeys(\%hash) in list cx'; 6359f11ffb7Safresh1is &mykeys([ 1..4 ]), 4, '&mykeys(\@array) in scalar cx'; 6369f11ffb7Safresh1lis [&mykeys([ 1..4 ])], [0..3], '&mykeys(\@array) in list cx'; 6379f11ffb7Safresh1 6389f11ffb7Safresh1SKIP: { 6399f11ffb7Safresh1 skip "no Hash::Util on miniperl", 2, if is_miniperl; 6409f11ffb7Safresh1 require Hash::Util; 6419f11ffb7Safresh1 sub Hash::Util::bucket_ratio (\%); 6429f11ffb7Safresh1 6439f11ffb7Safresh1 my %h = 1..2; 6449f11ffb7Safresh1 &mykeys(\%h) = 1024; 6459f11ffb7Safresh1 like Hash::Util::bucket_ratio(%h), qr!/(?:1024|2048)\z!, '&mykeys = changed number of buckets allocated'; 6469f11ffb7Safresh1 eval { (&mykeys(\%h)) = 1025; }; 6479f11ffb7Safresh1 like $@, qr/^Can't modify keys in list assignment at /; 6489f11ffb7Safresh1} 6499f11ffb7Safresh1 650898184e3Ssthentest_proto 'kill'; # set up mykill alias 651898184e3Ssthenif ($^O ne 'riscos') { 652898184e3Ssthen $tests ++; 653898184e3Ssthen ok( &mykill(0, $$), '&kill' ); 654898184e3Ssthen} 655898184e3Ssthen 656898184e3Ssthentest_proto 'lc', 'A', 'a'; 657898184e3Ssthentest_proto 'lcfirst', 'AA', 'aA'; 658898184e3Ssthentest_proto 'length', 'aaa', 3; 659898184e3Ssthentest_proto 'link'; 660898184e3Ssthentest_proto 'listen'; 661898184e3Ssthen 662898184e3Ssthentest_proto 'localtime'; 663898184e3Ssthen&CORE::localtime; 664898184e3Ssthenpass '&localtime without args does not crash'; ++$tests; 665898184e3Ssthen 666898184e3Ssthentest_proto 'lock'; 667898184e3Ssthen$tests += 6; 668898184e3Ssthenis \&mylock(\$foo), \$foo, '&lock retval when passed a scalar ref'; 669898184e3Ssthenlis [\&mylock(\$foo)], [\$foo], '&lock in list context'; 670898184e3Ssthenis &mylock(\@foo), \@foo, '&lock retval when passed an array ref'; 671898184e3Ssthenis &mylock(\%foo), \%foo, '&lock retval when passed a ash ref'; 672898184e3Ssthenis &mylock(\&foo), \&foo, '&lock retval when passed a code ref'; 673898184e3Ssthenis \&mylock(\*foo), \*foo, '&lock retval when passed a glob ref'; 674898184e3Ssthen 675898184e3Ssthentest_proto 'log'; 676898184e3Ssthen 677898184e3Ssthentest_proto 'mkdir'; 678898184e3Ssthen# mkdir is tested with implicit $_ at the end, to make the test easier 679898184e3Ssthen 680898184e3Ssthentest_proto "msg$_" for qw( ctl get rcv snd ); 681898184e3Ssthen 682898184e3Ssthentest_proto 'not'; 683898184e3Ssthen$tests += 2; 684898184e3Ssthenis &mynot(1), !1, '¬'; 685898184e3Ssthenlis [&mynot(0)], [!0], '¬ in list context'; 686898184e3Ssthen 687898184e3Ssthentest_proto 'oct', '666', 438; 688898184e3Ssthen 689898184e3Ssthentest_proto 'open'; 690898184e3Ssthen$tests += 5; 691898184e3Ssthen$file = 'test.pl'; 692898184e3Ssthenok &myopen('file'), '&open with 1 arg' or warn "1-arg open: $!"; 693898184e3Ssthenlike <file>, qr|^#|, 'result of &open with 1 arg'; 694898184e3Ssthenclose file; 695898184e3Ssthen{ 696898184e3Ssthen ok &myopen(my $fh, "test.pl"), 'two-arg &open'; 697898184e3Ssthen ok $fh, '&open autovivifies'; 698898184e3Ssthen like <$fh>, qr '^#', 'result of &open with 2 args'; 699898184e3Ssthen last if is_miniperl; 700898184e3Ssthen $tests +=2; 701898184e3Ssthen ok &myopen(my $fh2, "<", \"sharummbles"), 'retval of 3-arg &open'; 702898184e3Ssthen is <$fh2>, 'sharummbles', 'result of three-arg &open'; 703898184e3Ssthen} 704898184e3Ssthen 705898184e3Ssthentest_proto 'opendir'; 706b8851fccSafresh1test_proto 'ord', chr(utf8::unicode_to_native(64)), utf8::unicode_to_native(64); 707898184e3Ssthen 708898184e3Ssthentest_proto 'pack'; 709898184e3Ssthen$tests += 2; 710eac174f2Safresh1my $Perl_as_a_hex_string = 711eac174f2Safresh1 join "", map { sprintf("%2X", utf8::unicode_to_native($_)) } 0x50, 0x65, 0x72, 0x6c; 712b8851fccSafresh1is &mypack("H*", $Perl_as_a_hex_string), 'Perl', '&pack'; 713b8851fccSafresh1lis [&mypack("H*", $Perl_as_a_hex_string)], ['Perl'], '&pack in list context'; 714898184e3Ssthen 715898184e3Ssthentest_proto 'pipe'; 71691f110e0Safresh1 7179f11ffb7Safresh1test_proto 'pop'; 7189f11ffb7Safresh1$tests += 6; 7199f11ffb7Safresh1@ARGV = qw<a b c>; 7209f11ffb7Safresh1is &mypop(), 'c', 'retval of &pop with no args (@ARGV)'; 7219f11ffb7Safresh1is "@ARGV", "a b", 'effect of &pop on @ARGV'; 7229f11ffb7Safresh1sub { 7239f11ffb7Safresh1 is &mypop(), 'k', 'retval of &pop with no args (@_)'; 7249f11ffb7Safresh1 is "@_", "q j", 'effect of &pop on @_'; 7259f11ffb7Safresh1}->(qw(q j k)); 7269f11ffb7Safresh1{ 7279f11ffb7Safresh1 my @a = 1..4; 7289f11ffb7Safresh1 is &mypop(\@a), 4, 'retval of &pop'; 7299f11ffb7Safresh1 lis [@a], [1..3], 'effect of &pop'; 7309f11ffb7Safresh1} 7319f11ffb7Safresh1 73291f110e0Safresh1test_proto 'pos'; 73391f110e0Safresh1$tests += 4; 73491f110e0Safresh1$_ = "hello"; 73591f110e0Safresh1pos = 3; 73691f110e0Safresh1is &mypos, 3, 'reading &pos without args'; 73791f110e0Safresh1&mypos = 4; 73891f110e0Safresh1is pos, 4, 'writing to &pos without args'; 73991f110e0Safresh1{ 74091f110e0Safresh1 my $x = "gubai"; 74191f110e0Safresh1 pos $x = 3; 74291f110e0Safresh1 is &mypos(\$x), 3, 'reading &pos without args'; 74391f110e0Safresh1 &mypos(\$x) = 4; 74491f110e0Safresh1 is pos $x, 4, 'writing to &pos without args'; 74591f110e0Safresh1} 74691f110e0Safresh1 74791f110e0Safresh1test_proto 'prototype'; 74891f110e0Safresh1$tests++; 74991f110e0Safresh1is &myprototype(\&myprototype), prototype("CORE::prototype"), '&prototype'; 75091f110e0Safresh1 7519f11ffb7Safresh1test_proto 'push'; 7529f11ffb7Safresh1$tests += 2; 7539f11ffb7Safresh1{ 7549f11ffb7Safresh1 my @a = qw<a b c>; 7559f11ffb7Safresh1 is &mypush(\@a, "d", "e"), 5, 'retval of &push'; 7569f11ffb7Safresh1 is "@a", "a b c d e", 'effect of &push'; 7579f11ffb7Safresh1} 7589f11ffb7Safresh1 759898184e3Ssthentest_proto 'quotemeta', '$', '\$'; 760898184e3Ssthen 761898184e3Ssthentest_proto 'rand'; 762898184e3Ssthen$tests += 3; 7636fb12b70Safresh1my $r = &CORE::rand; 7646fb12b70Safresh1ok eval { 7656fb12b70Safresh1 use warnings FATAL => qw{numeric uninitialized}; 7666fb12b70Safresh1 $r >= 0 && $r < 1; 7676fb12b70Safresh1}, '&rand returns a valid number'; 768898184e3Ssthenunlike join(" ", &CORE::rand), qr/ /, '&rand in list context'; 76991f110e0Safresh1&cmp_ok(&CORE::rand(78), qw '< 78', '&rand with 1 arg'); 770898184e3Ssthen 771898184e3Ssthentest_proto 'read'; 772898184e3Ssthen{ 773898184e3Ssthen last if is_miniperl; 774898184e3Ssthen $tests += 5; 775898184e3Ssthen open my $fh, "<", \(my $buff = 'morays have their mores'); 776898184e3Ssthen ok &myread($fh, \my $input, 6), '&read with 3 args'; 777898184e3Ssthen is $input, 'morays', 'value read by 3-arg &read'; 778898184e3Ssthen ok &myread($fh, \$input, 6, 6), '&read with 4 args'; 779898184e3Ssthen is $input, 'morays have ', 'value read by 4-arg &read'; 780898184e3Ssthen is +()=&myread($fh, \$input, 6), 1, '&read in list context'; 781898184e3Ssthen} 782898184e3Ssthen 783898184e3Ssthentest_proto 'readdir'; 784898184e3Ssthen 785898184e3Ssthentest_proto 'readline'; 786898184e3Ssthen{ 787898184e3Ssthen local *ARGV = *DATA; 788898184e3Ssthen $tests ++; 789898184e3Ssthen is scalar &myreadline, 790898184e3Ssthen "I wandered lonely as a cloud\n", '&readline w/no args'; 791898184e3Ssthen} 792898184e3Ssthen{ 793898184e3Ssthen last if is_miniperl; 794898184e3Ssthen $tests += 2; 795898184e3Ssthen open my $fh, "<", \(my $buff = <<END); 796898184e3SsthenThe Recursive Problem 797898184e3Ssthen--------------------- 798898184e3SsthenI have a problem I cannot solve. 799898184e3SsthenThe problem is that I cannot solve it. 800898184e3SsthenEND 801898184e3Ssthen is &myreadline($fh), "The Recursive Problem\n", 802898184e3Ssthen '&readline with 1 arg'; 803898184e3Ssthen lis [&myreadline($fh)], [ 804898184e3Ssthen "---------------------\n", 805898184e3Ssthen "I have a problem I cannot solve.\n", 806898184e3Ssthen "The problem is that I cannot solve it.\n", 807898184e3Ssthen ], '&readline in list context'; 808898184e3Ssthen} 809898184e3Ssthen 810898184e3Ssthentest_proto 'readlink'; 811898184e3Ssthentest_proto 'readpipe'; 812898184e3Ssthentest_proto 'recv'; 813898184e3Ssthen 814898184e3Ssthenuse if !is_miniperl, File::Spec::Functions, qw "catfile"; 815898184e3Ssthenuse if !is_miniperl, File::Temp, 'tempdir'; 816898184e3Ssthen 817898184e3Ssthentest_proto 'rename'; 818898184e3Ssthen{ 819898184e3Ssthen last if is_miniperl; 820898184e3Ssthen $tests ++; 821898184e3Ssthen my $dir = tempdir(uc cleanup => 1); 822898184e3Ssthen my $tmpfilenam = catfile $dir, 'aaa'; 823898184e3Ssthen open my $fh, ">", $tmpfilenam or die "cannot open $tmpfilenam: $!"; 824898184e3Ssthen close $fh or die "cannot close $tmpfilenam: $!"; 825898184e3Ssthen &myrename("$tmpfilenam", $tmpfilenam = catfile $dir,'bbb'); 826898184e3Ssthen ok open(my $fh, '>', $tmpfilenam), '&rename'; 827898184e3Ssthen} 828898184e3Ssthen 829898184e3Ssthentest_proto 'ref', [], 'ARRAY'; 830898184e3Ssthen 831898184e3Ssthentest_proto 'reset'; 832898184e3Ssthen$tests += 2; 833898184e3Ssthenmy $oncer = sub { "a" =~ m?a? }; 834898184e3Ssthen&$oncer; 835898184e3Ssthen&myreset; 83691f110e0Safresh1ok &$oncer, '&reset with no args'; 837898184e3Ssthenpackage resettest { 838898184e3Ssthen $b = "c"; 839898184e3Ssthen $banana = "cream"; 840898184e3Ssthen &::myreset('b'); 84191f110e0Safresh1 ::lis [$b,$banana],[(undef)x2], '1-arg &reset'; 842898184e3Ssthen} 843898184e3Ssthen 844898184e3Ssthentest_proto 'reverse'; 845898184e3Ssthen$tests += 2; 846898184e3Ssthenis &myreverse('reward'), 'drawer', '&reverse'; 847898184e3Ssthenlis [&myreverse(qw 'dog bites man')], [qw 'man bites dog'], 848898184e3Ssthen '&reverse in list context'; 849898184e3Ssthen 850898184e3Ssthentest_proto 'rewinddir'; 851898184e3Ssthen 852898184e3Ssthentest_proto 'rindex'; 853898184e3Ssthen$tests += 3; 854898184e3Ssthenis &myrindex("foffooo","o",2),1,'&rindex'; 855898184e3Ssthenlis [&myrindex("foffooo","o",2)],[1],'&rindex in list context'; 856898184e3Ssthenis &myrindex("foffooo","o"),6,'&rindex with 2 args'; 857898184e3Ssthen 858898184e3Ssthentest_proto 'rmdir'; 859898184e3Ssthen 86091f110e0Safresh1test_proto 'scalar'; 86191f110e0Safresh1$tests += 2; 86291f110e0Safresh1is &myscalar(3), 3, '&scalar'; 86391f110e0Safresh1lis [&myscalar(3)], [3], '&scalar in list cx'; 86491f110e0Safresh1 865898184e3Ssthentest_proto 'seek'; 866898184e3Ssthen{ 867898184e3Ssthen last if is_miniperl; 868898184e3Ssthen $tests += 1; 869898184e3Ssthen open my $fh, "<", \"misled" or die $!; 870898184e3Ssthen &myseek($fh, 2, 0); 871898184e3Ssthen is <$fh>, 'sled', '&seek in action'; 872898184e3Ssthen} 873898184e3Ssthen 874898184e3Ssthentest_proto 'seekdir'; 875898184e3Ssthen 876898184e3Ssthen# Can’t test_proto, as it has none 877898184e3Ssthen$tests += 8; 878898184e3Ssthen*myselect = \&CORE::select; 879898184e3Ssthenis defined prototype &myselect, defined prototype "CORE::select", 880898184e3Ssthen 'prototype of &select (or lack thereof)'; 881898184e3Ssthenis &myselect, select, '&select with no args'; 882898184e3Ssthen{ 883898184e3Ssthen my $prev = select; 884898184e3Ssthen is &myselect(my $fh), $prev, '&select($arg) retval'; 885898184e3Ssthen is lc ref $fh, 'glob', '&select autovivifies'; 8869f11ffb7Safresh1 is select, $fh, '&select selects'; 887898184e3Ssthen select $prev; 888898184e3Ssthen} 889898184e3Sstheneval { &myselect(1,2) }; 890898184e3Ssthenlike $@, qr/^Not enough arguments for select system call at /, 891eac174f2Safresh1 '&myselect($two,$args)'; 892898184e3Sstheneval { &myselect(1,2,3) }; 893898184e3Ssthenlike $@, qr/^Not enough arguments for select system call at /, 894eac174f2Safresh1 '&myselect($with,$three,$args)'; 895898184e3Sstheneval { &myselect(1,2,3,4,5) }; 896898184e3Ssthenlike $@, qr/^Too many arguments for select system call at /, 897eac174f2Safresh1 '&myselect($a,$total,$of,$five,$args)'; 898b8851fccSafresh1unless ($^O eq "MSWin32" && is_miniperl) { 899898184e3Ssthen &myselect((undef)x3,.25); 900898184e3Ssthen # Just have to assume that worked. :-) If we get here, at least it didn’t 901898184e3Ssthen # crash or anything. 902b8851fccSafresh1 # select() is unimplemented in Win32 miniperl 903b8851fccSafresh1} 904898184e3Ssthen 905898184e3Ssthentest_proto "sem$_" for qw "ctl get op"; 906898184e3Ssthen 907898184e3Ssthentest_proto 'send'; 908898184e3Ssthen 909898184e3Ssthentest_proto "set$_" for qw ' 910898184e3Ssthen grent hostent netent 911898184e3Ssthen'; 912898184e3Ssthen 913898184e3Ssthentest_proto 'setpgrp'; 914898184e3Ssthen$tests +=2; 915898184e3Sstheneval { &mysetpgrp( 0) }; 916898184e3Ssthenpass "&setpgrp with one argument"; 917898184e3Sstheneval { &mysetpgrp }; 918898184e3Ssthenpass "&setpgrp with no arguments"; 919898184e3Ssthen 920898184e3Ssthentest_proto "set$_" for qw ' 921898184e3Ssthen priority protoent pwent servent sockopt 922898184e3Ssthen'; 923898184e3Ssthen 9249f11ffb7Safresh1test_proto 'shift'; 9259f11ffb7Safresh1$tests += 6; 9269f11ffb7Safresh1@ARGV = qw<a b c>; 9279f11ffb7Safresh1is &myshift(), 'a', 'retval of &shift with no args (@ARGV)'; 9289f11ffb7Safresh1is "@ARGV", "b c", 'effect of &shift on @ARGV'; 9299f11ffb7Safresh1sub { 9309f11ffb7Safresh1 is &myshift(), 'q', 'retval of &shift with no args (@_)'; 9319f11ffb7Safresh1 is "@_", "j k", 'effect of &shift on @_'; 9329f11ffb7Safresh1}->(qw(q j k)); 9339f11ffb7Safresh1{ 9349f11ffb7Safresh1 my @a = 1..4; 9359f11ffb7Safresh1 is &myshift(\@a), 1, 'retval of &shift'; 9369f11ffb7Safresh1 lis [@a], [2..4], 'effect of &shift'; 9379f11ffb7Safresh1} 9389f11ffb7Safresh1 939898184e3Ssthentest_proto "shm$_" for qw "ctl get read write"; 940898184e3Ssthentest_proto 'shutdown'; 941898184e3Ssthentest_proto 'sin'; 942898184e3Ssthentest_proto 'sleep'; 943898184e3Ssthentest_proto "socket$_" for "", "pair"; 944898184e3Ssthen 9459f11ffb7Safresh1test_proto 'splice'; 9469f11ffb7Safresh1$tests += 8; 9479f11ffb7Safresh1{ 9489f11ffb7Safresh1 my @a = qw<a b c>; 9499f11ffb7Safresh1 is &mysplice(\@a, 1), 'c', 'retval of 2-arg &splice in scalar context'; 9509f11ffb7Safresh1 lis \@a, ['a'], 'effect of 2-arg &splice in scalar context'; 9519f11ffb7Safresh1 @a = qw<a b c>; 9529f11ffb7Safresh1 lis [&mysplice(\@a, 1)], ['b','c'], 'retval of 2-arg &splice in list cx'; 9539f11ffb7Safresh1 lis \@a, ['a'], 'effect of 2-arg &splice in list context'; 9549f11ffb7Safresh1 @a = qw<a b c d>; 9559f11ffb7Safresh1 lis [&mysplice(\@a,1,2)],['b','c'], 'retval of 3-arg &splice in list cx'; 9569f11ffb7Safresh1 lis \@a, ['a','d'], 'effect of 3-arg &splice in list context'; 9579f11ffb7Safresh1 @a = qw<a b c d>; 9589f11ffb7Safresh1 lis [&mysplice(\@a,1,1,'e')],['b'], 'retval of 4-arg &splice in list cx'; 9599f11ffb7Safresh1 lis \@a, [qw<a e c d>], 'effect of 4-arg &splice in list context'; 9609f11ffb7Safresh1} 9619f11ffb7Safresh1 962898184e3Ssthentest_proto 'sprintf'; 963898184e3Ssthen$tests += 2; 964898184e3Ssthenis &mysprintf("%x", 65), '41', '&sprintf'; 965898184e3Ssthenlis [&mysprintf("%x", '65')], ['41'], '&sprintf in list context'; 966898184e3Ssthen 967898184e3Ssthentest_proto 'sqrt', 4, 2; 968898184e3Ssthen 969898184e3Ssthentest_proto 'srand'; 970898184e3Ssthen$tests ++; 971898184e3Ssthen&CORE::srand; 97291f110e0Safresh1() = &CORE::srand; 973898184e3Ssthenpass '&srand with no args does not crash'; 974898184e3Ssthen 97591f110e0Safresh1test_proto 'study'; 97691f110e0Safresh1 977898184e3Ssthentest_proto 'substr'; 978898184e3Ssthen$tests += 5; 979898184e3Ssthen$_ = "abc"; 980898184e3Ssthenis &mysubstr($_, 1, 1, "d"), 'b', '4-arg &substr'; 981898184e3Ssthenis $_, 'adc', 'what 4-arg &substr does'; 982898184e3Ssthenis &mysubstr("abc", 1, 1), 'b', '3-arg &substr'; 983898184e3Ssthenis &mysubstr("abc", 1), 'bc', '2-arg &substr'; 984898184e3Ssthen&mysubstr($_, 1) = 'long'; 985898184e3Ssthenis $_, 'along', 'lvalue &substr'; 986898184e3Ssthen 987898184e3Ssthentest_proto 'symlink'; 988898184e3Ssthentest_proto 'syscall'; 989898184e3Ssthen 990898184e3Ssthentest_proto 'sysopen'; 991898184e3Ssthen$tests +=2; 992898184e3Ssthen{ 993898184e3Ssthen &mysysopen(my $fh, 'test.pl', 0); 994898184e3Ssthen pass '&sysopen does not crash with 3 args'; 995898184e3Ssthen ok $fh, 'sysopen autovivifies'; 996898184e3Ssthen} 997898184e3Ssthen 998898184e3Ssthentest_proto 'sysread'; 999898184e3Ssthentest_proto 'sysseek'; 1000898184e3Ssthentest_proto 'syswrite'; 1001898184e3Ssthen 1002898184e3Ssthentest_proto 'tell'; 1003898184e3Ssthen{ 1004898184e3Ssthen $tests += 2; 1005898184e3Ssthen open my $fh, "test.pl" or die "Cannot open test.pl"; 1006898184e3Ssthen <$fh>; 1007898184e3Ssthen is &mytell(), tell($fh), '&tell with no args'; 1008898184e3Ssthen is &mytell($fh), tell($fh), '&tell with an arg'; 1009898184e3Ssthen} 1010898184e3Ssthen 1011898184e3Ssthentest_proto 'telldir'; 1012898184e3Ssthen 1013898184e3Ssthentest_proto 'tie'; 1014898184e3Ssthentest_proto 'tied'; 1015898184e3Ssthen$tests += 3; 1016898184e3Ssthen{ 1017898184e3Ssthen my $fetches; 1018898184e3Ssthen package tier { 1019898184e3Ssthen sub TIESCALAR { bless[] } 1020898184e3Ssthen sub FETCH { ++$fetches } 1021898184e3Ssthen } 1022898184e3Ssthen my $tied; 1023898184e3Ssthen my $obj = &mytie(\$tied, 'tier'); 1024898184e3Ssthen is &mytied(\$tied), $obj, '&tie and &tied retvals'; 1025898184e3Ssthen () = "$tied"; 1026898184e3Ssthen is $fetches, 1, '&tie actually ties'; 1027898184e3Ssthen &CORE::untie(\$tied); 1028898184e3Ssthen () = "$tied"; 1029898184e3Ssthen is $fetches, 1, '&untie unties'; 1030898184e3Ssthen} 1031898184e3Ssthen 1032898184e3Ssthentest_proto 'time'; 1033898184e3Ssthen$tests += 2; 1034b8851fccSafresh1like &mytime, qr/^\d+\z/, '&time in scalar context'; 1035b8851fccSafresh1like join('-', &mytime), qr/^\d+\z/, '&time in list context'; 1036898184e3Ssthen 1037898184e3Ssthentest_proto 'times'; 1038898184e3Ssthen$tests += 2; 1039b8851fccSafresh1like &mytimes, qr/^[\d.]+\z/, '× in scalar context'; 1040b8851fccSafresh1like join('-',&mytimes), qr/^[\d.]+-[\d.]+-[\d.]+-[\d.]+\z/, 1041898184e3Ssthen '× in list context'; 1042898184e3Ssthen 1043898184e3Ssthentest_proto 'uc', 'aa', 'AA'; 1044898184e3Ssthentest_proto 'ucfirst', 'aa', "Aa"; 1045898184e3Ssthen 1046898184e3Ssthentest_proto 'umask'; 1047898184e3Ssthen$tests ++; 1048898184e3Ssthenis &myumask, umask, '&umask with no args'; 1049898184e3Ssthen 105091f110e0Safresh1test_proto 'undef'; 105191f110e0Safresh1$tests += 12; 105291f110e0Safresh1is &myundef(), undef, '&undef returns undef'; 105391f110e0Safresh1lis [&myundef()], [undef], '&undef returns undef in list cx'; 105491f110e0Safresh1lis [&myundef(\$_)], [undef], '&undef(...) returns undef in list cx'; 105591f110e0Safresh1is \&myundef(), \undef, '&undef returns the right undef'; 105691f110e0Safresh1$_ = 'anserine questions'; 105791f110e0Safresh1&myundef(\$_); 105891f110e0Safresh1is $_, undef, '&undef(\$_) undefines $_'; 105991f110e0Safresh1@_ = 1..3; 106091f110e0Safresh1&myundef(\@_); 106191f110e0Safresh1is @_, 0, '&undef(\@_) undefines @_'; 106291f110e0Safresh1%_ = 1..4; 106391f110e0Safresh1&myundef(\%_); 106491f110e0Safresh1ok !%_, '&undef(\%_) undefines %_'; 106591f110e0Safresh1&myundef(\&utf8::valid); # nobody should be using this :-) 106691f110e0Safresh1ok !defined &utf8::valid, '&undef(\&foo) undefines &foo'; 106791f110e0Safresh1@_ = \*_; 106891f110e0Safresh1&myundef; 106991f110e0Safresh1is *_{ARRAY}, undef, '@_=\*_, &undef undefines *_'; 107091f110e0Safresh1@_ = \*_; 107191f110e0Safresh1&myundef(\*_); 107291f110e0Safresh1is *_{ARRAY}, undef, '&undef(\*_) undefines *_'; 107391f110e0Safresh1(&myundef(), @_) = 1..10; 107491f110e0Safresh1lis \@_, [2..10], 'list assignment to &undef()'; 107591f110e0Safresh1ok !defined undef, 'list assignment to &undef() does not affect undef'; 107691f110e0Safresh1undef @_; 107791f110e0Safresh1 1078898184e3Ssthentest_proto 'unpack'; 1079898184e3Ssthen$tests += 2; 1080eac174f2Safresh1my $abcd_as_a_hex_string = 1081eac174f2Safresh1 join "", map { sprintf("%2X", utf8::unicode_to_native($_)) } 0x61, 0x62, 0x63, 0x64; 1082eac174f2Safresh1my $bcde_as_a_hex_string = 1083eac174f2Safresh1 join "", map { sprintf("%2X", utf8::unicode_to_native($_)) } 0x62, 0x63, 0x64, 0x65; 1084898184e3Ssthen$_ = 'abcd'; 1085b8851fccSafresh1is &myunpack("H*"), $abcd_as_a_hex_string, '&unpack with one arg'; 1086b8851fccSafresh1is &myunpack("H*", "bcde"), $bcde_as_a_hex_string, '&unpack with two arg'; 1087898184e3Ssthen 1088898184e3Ssthen 10899f11ffb7Safresh1test_proto 'unshift'; 10909f11ffb7Safresh1$tests += 2; 10919f11ffb7Safresh1{ 10929f11ffb7Safresh1 my @a = qw<a b c>; 10939f11ffb7Safresh1 is &myunshift(\@a, "d", "e"), 5, 'retval of &unshift'; 10949f11ffb7Safresh1 is "@a", "d e a b c", 'effect of &unshift'; 10959f11ffb7Safresh1} 10969f11ffb7Safresh1 1097898184e3Ssthentest_proto 'untie'; # behaviour already tested along with tie(d) 1098898184e3Ssthen 1099898184e3Ssthentest_proto 'utime'; 1100898184e3Ssthen$tests += 2; 1101898184e3Ssthenis &myutime(undef,undef), 0, '&utime'; 1102898184e3Ssthenlis [&myutime(undef,undef)], [0], '&utime in list context'; 1103898184e3Ssthen 11049f11ffb7Safresh1test_proto 'values'; 11059f11ffb7Safresh1$tests += 4; 11069f11ffb7Safresh1is &myvalues({ 1..4 }), 2, '&myvalues(\%hash) in scalar cx'; 11079f11ffb7Safresh1lis [sort &myvalues({1..4})], [2,4], '&myvalues(\%hash) in list cx'; 11089f11ffb7Safresh1is &myvalues([ 1..4 ]), 4, '&myvalues(\@array) in scalar cx'; 11099f11ffb7Safresh1lis [&myvalues([ 1..4 ])], [1..4], '&myvalues(\@array) in list cx'; 11109f11ffb7Safresh1 1111898184e3Ssthentest_proto 'vec'; 1112898184e3Ssthen$tests += 3; 1113898184e3Ssthenis &myvec("foo", 0, 4), 6, '&vec'; 1114898184e3Ssthenlis [&myvec("foo", 0, 4)], [6], '&vec in list context'; 1115898184e3Ssthen$tmp = "foo"; 1116898184e3Ssthen++&myvec($tmp,0,4); 1117898184e3Ssthenis $tmp, "goo", 'lvalue &vec'; 1118898184e3Ssthen 1119898184e3Ssthentest_proto 'wait'; 1120898184e3Ssthentest_proto 'waitpid'; 1121898184e3Ssthen 1122898184e3Ssthentest_proto 'wantarray'; 1123898184e3Ssthen$tests += 4; 1124898184e3Ssthenmy $context; 1125898184e3Ssthenmy $cx_sub = sub { 1126898184e3Ssthen $context = qw[void scalar list][&mywantarray + defined mywantarray()] 1127898184e3Ssthen}; 1128898184e3Ssthen() = &$cx_sub; 1129898184e3Ssthenis $context, 'list', '&wantarray with caller in list context'; 1130898184e3Ssthenscalar &$cx_sub; 1131898184e3Ssthenis($context, 'scalar', '&wantarray with caller in scalar context'); 1132898184e3Ssthen&$cx_sub; 1133898184e3Ssthenis($context, 'void', '&wantarray with caller in void context'); 1134898184e3Ssthenlis [&mywantarray],[wantarray], '&wantarray itself in list context'; 1135898184e3Ssthen 1136898184e3Ssthentest_proto 'warn'; 1137898184e3Ssthen{ $tests += 3; 1138898184e3Ssthen my $w; 1139898184e3Ssthen local $SIG{__WARN__} = sub { $w = shift }; 1140898184e3Ssthen is &mywarn('a'), 1, '&warn retval'; 1141898184e3Ssthen is $w, "a at " . __FILE__ . " line " . (__LINE__-1) . ".\n", 'warning'; 1142898184e3Ssthen lis [&mywarn()], [1], '&warn retval in list context'; 1143898184e3Ssthen} 1144898184e3Ssthen 1145898184e3Ssthentest_proto 'write'; 1146898184e3Ssthen$tests ++; 1147898184e3Sstheneval {&mywrite}; 1148898184e3Ssthenlike $@, qr'^Undefined format "STDOUT" called', 1149898184e3Ssthen "&write without arguments can handle the null"; 1150898184e3Ssthen 1151898184e3Ssthen# This is just a check to make sure we have tested everything. If we 1152898184e3Ssthen# haven’t, then either the sub needs to be tested or the list in 1153898184e3Ssthen# gv.c is wrong. 1154898184e3Ssthen{ 1155898184e3Ssthen last if is_miniperl; 1156898184e3Ssthen require File::Spec::Functions; 1157898184e3Ssthen my $keywords_file = 1158898184e3Ssthen File::Spec::Functions::catfile( 1159898184e3Ssthen File::Spec::Functions::updir,'regen','keywords.pl' 1160898184e3Ssthen ); 116156d68f1eSafresh1 my %nottest_words = map { $_ => 1 } qw( 1162e0680481Safresh1 ADJUST AUTOLOAD BEGIN CHECK CORE DESTROY END INIT UNITCHECK 116356d68f1eSafresh1 __DATA__ __END__ 1164e0680481Safresh1 and catch class cmp default defer do dump else elsif eq eval field finally 1165e0680481Safresh1 for foreach format ge given goto grep gt if isa last le local lt m map 1166e0680481Safresh1 method my ne next no or our package print printf q qq qr qw qx redo require 1167e0680481Safresh1 return s say sort state sub tr try unless until use when while x xor y 116856d68f1eSafresh1 ); 1169898184e3Ssthen open my $kh, $keywords_file 1170898184e3Ssthen or die "$0 cannot open $keywords_file: $!"; 1171898184e3Ssthen while(<$kh>) { 117291f110e0Safresh1 if (m?__END__?..${\0} and /^[-+](.*)/) { 1173898184e3Ssthen my $word = $1; 117456d68f1eSafresh1 next if $nottest_words{$word}; 1175898184e3Ssthen $tests ++; 1176898184e3Ssthen ok exists &{"my$word"} 1177898184e3Ssthen || (eval{&{"CORE::$word"}}, $@ =~ /cannot be called directly/), 1178898184e3Ssthen "$word either has been tested or is not ampable"; 1179898184e3Ssthen } 1180898184e3Ssthen } 1181898184e3Ssthen} 1182898184e3Ssthen 1183898184e3Ssthen# Add new tests above this line. 1184898184e3Ssthen 1185898184e3Ssthen# This test must come last (before the test count test): 1186898184e3Ssthen 1187898184e3Ssthen{ 1188898184e3Ssthen last if is_miniperl; 1189898184e3Ssthen require Cwd; 1190898184e3Ssthen import Cwd; 1191898184e3Ssthen $tests += 3; 1192898184e3Ssthen require File::Temp ; 1193898184e3Ssthen my $dir = File::Temp::tempdir(uc cleanup => 1); 1194898184e3Ssthen my $cwd = cwd(); 1195898184e3Ssthen chdir($dir); 1196898184e3Ssthen 1197898184e3Ssthen # Make sure that implicit $_ is not applied to mkdir’s second argument. 1198898184e3Ssthen local $^W = 1; 1199898184e3Ssthen my $warnings; 1200898184e3Ssthen local $SIG{__WARN__} = sub { ++$warnings }; 1201898184e3Ssthen 1202b8851fccSafresh1 local $_ = 'Phoo'; 1203898184e3Ssthen ok &mymkdir(), '&mkdir'; 1204898184e3Ssthen like <*>, qr/^phoo(.DIR)?\z/i, 'mkdir works with implicit $_'; 1205898184e3Ssthen 1206898184e3Ssthen is $warnings, undef, 'no implicit $_ for second argument to mkdir'; 1207898184e3Ssthen 1208898184e3Ssthen chdir($cwd); # so auto-cleanup can remove $dir 1209898184e3Ssthen} 1210898184e3Ssthen 1211898184e3Ssthen# ------------ END TESTING ----------- # 1212898184e3Ssthen 1213898184e3Ssthendone_testing $tests; 1214898184e3Ssthen 1215898184e3Ssthen#line 3 frob 1216898184e3Ssthen 1217898184e3Ssthensub file { &CORE::__FILE__ } 1218898184e3Ssthensub line { &CORE::__LINE__ } # 5 1219898184e3Ssthensub dier { &CORE::die(@_) } # 6 1220898184e3Ssthenpackage stribble; 1221898184e3Ssthensub main::pakg { &CORE::__PACKAGE__ } 1222898184e3Ssthen 1223898184e3Ssthen# Please do not add new tests here. 1224898184e3Ssthenpackage main; 1225898184e3SsthenCORE::__DATA__ 1226898184e3SsthenI wandered lonely as a cloud 1227b8851fccSafresh1That floats on high o'er vales and hills, 1228898184e3SsthenAnd all at once I saw a crowd, 1229898184e3SsthenA host of golden daffodils! 1230898184e3SsthenBeside the lake, beneath the trees, 1231898184e3SsthenFluttering, dancing, in the breeze. 1232898184e3Ssthen-- Wordsworth 1233