7 $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
15 my($ok, $info, $todo) = @_;
17 # You have to do it this way or VMS will get confused.
18 printf "%s $test%s\n", $ok ? "ok" : "not ok",
19 $todo ? " # TODO $todo" : '';
22 printf "# Failed test at line %d\n", (caller)[2];
23 print "# $info\n" if defined $info;
33 printf "ok $test # skipped%s\n", defined $reason ? ": $reason" : '';
41 $Is_MSWin32 = $^O eq 'MSWin32';
42 $Is_NetWare = $^O eq 'NetWare';
43 $Is_VMS = $^O eq 'VMS';
44 $Is_Dos = $^O eq 'dos';
45 $Is_os2 = $^O eq 'os2';
46 $Is_Cygwin = $^O eq 'cygwin';
47 $Is_MacOS = $^O eq 'MacOS';
48 $Is_MPE = $^O eq 'mpeix';
50 $PERL = ($Is_NetWare ? 'perl' :
51 ($Is_MacOS || $Is_VMS) ? $^X :
52 $Is_MSWin32 ? '.\perl' :
55 eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
56 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
58 if ($Is_MSWin32) { ok `set FOO` =~ /^(?:FOO=)?hi there$/; }
59 elsif ($Is_MacOS) { ok "1 # skipped", 1; }
60 elsif ($Is_VMS) { ok `write sys\$output f\$trnlnm("FOO")` eq "hi there\n"; }
61 else { ok `echo \$FOO` eq "hi there\n"; }
63 unlink 'ajslkdfpqjsjfk';
65 open(FOO,'ajslkdfpqjsjfk');
67 close FOO; # just mention it, squelch used-only-once
69 if ($Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE || $Is_MacOS) {
70 skip('SIGINT not safe on this platform') for 1..4;
73 # the next tests are done in a subprocess because sh spits out a
74 # newline onto stderr when a child process kills itself with SIGINT.
75 # We use a pipe rather than system() because the VMS command buffer
76 # would overflow with a command that long.
78 open( CMDPIPE, "| $PERL");
80 print CMDPIPE <<'END';
82 $| = 1; # command buffering
84 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
85 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
86 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok 4\n";
89 if (($x = pop(@_)) eq "INT") {
93 print "not ok 3 ($x @_)\n";
101 open( CMDPIPE, "| $PERL");
102 print CMDPIPE <<'END';
113 $| = 1; # command buffering
116 local $SIG{"INT"}=x();
117 print ""; # Needed to expose failure in 5.8.0 (why?)
121 kill "INT",$$; sleep 1;
127 $? >>= 8 if $^O eq 'VMS'; # POSIX status hiding in 2nd byte
128 print $? & 0xFF ? "ok 6\n" : "not ok 6\n";
134 @val1 = @ENV{keys(%ENV)};
135 @val2 = values(%ENV);
136 ok join(':',@val1) eq join(':',@val2);
140 'foobarbaz' =~ /b(a)r/;
147 @a = qw(foo bar baz);
148 ok "@a" eq "foo bar baz", "@a";
151 ok "@a" eq "foo,bar,baz", "@a";
156 $h{'foo', 'bar'} = 1;
157 ok((keys %h)[0] eq "foo\034bar", (keys %h)[0]);
161 $h{'foo', 'bar'} = 1;
162 ok((keys %h)[0] eq 'fooxbar', (keys %h)[0]);
167 skip('$? + system are broken on MacPerl') for 1..2;
170 system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(0)"];
172 system qq[$PERL "-I../lib" -e "use vmsish qw(hushed); exit(1)"];
176 eval { die "foo\n" };
177 ok $@ eq "foo\n", $@;
181 ok $@ =~ /^Modification of a read-only value attempted/;
186 chomp($wd = `/usr/bin/fullpath -t`);
188 elsif($Is_Cygwin || $Config{'d_procselfexe'}) {
189 # Cygwin turns the symlink into the real file
194 $wd = Cwd::sys_cwd();
202 my $perl = ($Is_MacOS || $Is_VMS) ? $^X : "$wd/perl";
205 $script = "$wd/show-shebang";
209 $perl = "$wd/perl.exe";
210 $script = "$wd/show-shebang.bat";
225 $script = "./show-shebang";
228 $script = ":show-shebang";
231 $script = "[]show-shebang";
233 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
235 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
239 $s1 = "\$^X is $perl, \$0 is $script\n";
240 ok open(SCRIPT, ">$script"), $!;
241 ok print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
244 print "\$^X is $^X, \$0 is $0\n";
246 ok close(SCRIPT), $!;
247 ok chmod(0755, $script), $!;
248 $_ = ($Is_MacOS || $Is_VMS) ? `$perl $script` : `$script`;
249 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
250 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
251 s{is perl}{is $perl}; # for systems where $^X is only a basename
253 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:");
254 $_ = `$perl $script`;
255 s/\.exe//i if $Is_Dos or $Is_os2;
257 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`");
258 ok unlink($script), $!;
262 ok $] >= 5.00319, $];
264 ok $^T > 850000000, $^T;
266 if ($Is_VMS || $Is_Dos || $Is_MacOS) {
267 skip("%ENV manipulations fail or aren't safe on $^O") for 1..3;
271 $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0;
275 $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0;
276 ok ($Is_MSWin32 ? (`set foo 2>NUL` eq "")
277 : (`echo \$foo` eq "\n") );
279 $ENV{__NoNeSuCh} = "foo";
281 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
283 ok ($Is_MSWin32 ? (`set __NoNeSuCh` =~ /^(?:__NoNeSuCh=)?foo$/)
284 : (`echo \$__NoNeSuCh` eq "foo\n") );
285 if ($^O =~ /^(linux|freebsd)$/ &&
286 open CMDLINE, "/proc/$$/cmdline") {
287 chomp(my $line = scalar <CMDLINE>);
288 my $me = (split /\0/, $line)[0];
289 ok($me eq $0, 'altering $0 is effective');
292 skip("\$0 check only on Linux and FreeBSD with /proc");
299 local $SIG{'__WARN__'} = sub { $ok = 0; $warn = join '', @_; };
301 ok($ok, $warn, $Is_VMS ? "'\$!=undef' does throw a warning" : '');
304 # test case-insignificance of %ENV (these tests must be enabled only
305 # when perl is compiled with -DENV_IS_CASELESS)
306 if ($Is_MSWin32 || $Is_NetWare) {
310 ok (scalar(keys(%ENV)) == 1);
311 ok exists($ENV{'FOo'});
312 ok (delete($ENV{'foO'}) eq 'baz');
313 ok (scalar(keys(%ENV)) == 0);
316 skip('no caseless %ENV support') for 1..4;
322 # Make sure Errno hasn't been prematurely autoloaded
324 ok !defined %Errno::;
326 # Test auto-loading of Errno when %! is used
335 # Make sure that Errno loading doesn't clobber $!
338 delete $INC{"Errno.pm"};
340 open(FOO, "nonesuch"); # Generate ENOENT
341 my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time
344 ok $^S == 0 && defined $^S;
345 eval { ok $^S == 1 };
346 eval " BEGIN { ok ! defined \$^S } ";
347 ok $^S == 0 && defined $^S;
350 eval { ${^TAINT} = 1 };
353 # 5.6.1 had a bug: @+ and @- were not properly interpolated
354 # into double-quoted strings
355 # 20020414 mjd-perl-patch+@plover.com
356 "I like pie" =~ /(I) (like) (pie)/;
357 ok "@-" eq "0 0 2 7";
358 ok "@+" eq "10 1 6 10";
360 # Tests for the magic get of $\
373 $ok = "a$\b" eq "aa\0bb";