7 $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
14 my($ok, $info, $todo) = @_;
16 # You have to do it this way or VMS will get confused.
17 printf "%s $test%s\n", $ok ? "ok" : "not ok",
18 $todo ? " # TODO $todo" : '';
21 printf "# Failed test at line %d\n", (caller)[2];
22 print "# $info" if defined $info;
32 printf "ok $test # skipped%s\n", defined $reason ? ": $reason" : '';
40 $Is_MSWin32 = $^O eq 'MSWin32';
41 $Is_NetWare = $^O eq 'NetWare';
42 $Is_VMS = $^O eq 'VMS';
43 $Is_Dos = $^O eq 'dos';
44 $Is_os2 = $^O eq 'os2';
45 $Is_Cygwin = $^O eq 'cygwin';
46 $Is_MacOS = $^O eq 'MacOS';
47 $Is_MPE = $^O eq 'mpeix';
49 $PERL = ($Is_NetWare ? 'perl' :
51 $Is_MSWin32 ? '.\perl' :
54 eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
55 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
57 if ($Is_MSWin32) { ok `set FOO` =~ /^(FOO=)?hi there$/; }
58 elsif ($Is_MacOS) { ok "1 # skipped", 1; }
59 else { ok `echo \$FOO` eq "hi there\n"; }
61 unlink 'ajslkdfpqjsjfk';
63 open(FOO,'ajslkdfpqjsjfk');
65 close FOO; # just mention it, squelch used-only-once
67 if ($Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE || $Is_MacOS) {
71 # the next tests are embedded inside system simply because sh spits out
72 # a newline onto stderr when a child process kills itself with SIGINT.
73 system './perl', '-e', <<'END';
75 $| = 1; # command buffering
77 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
78 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
79 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok 4\n";
82 if (($x = pop(@_)) eq "INT") {
86 print "not ok 3 ($x @_)\n";
95 @val1 = @ENV{keys(%ENV)};
97 ok join(':',@val1) eq join(':',@val2);
101 'foobarbaz' =~ /b(a)r/;
108 @a = qw(foo bar baz);
109 ok "@a" eq "foo bar baz", "@a";
112 ok "@a" eq "foo,bar,baz", "@a";
117 $h{'foo', 'bar'} = 1;
118 ok((keys %h)[0] eq "foo\034bar", (keys %h)[0]);
122 $h{'foo', 'bar'} = 1;
123 ok((keys %h)[0] eq 'fooxbar', (keys %h)[0]);
127 system qq[$PERL -e "exit(0)"];
129 system qq[$PERL -e "exit(1)"];
132 eval { die "foo\n" };
133 ok $@ eq "foo\n", $@;
140 chomp($wd = `/usr/bin/fullpath -t`);
143 # Cygwin turns the symlink into the real file
148 $wd = Cwd::sys_cwd();
156 my $perl = $Is_MacOS ? $^X : "$wd/perl";
159 $script = "$wd/show-shebang";
163 $perl = "$wd/perl.exe";
164 $script = "$wd/show-shebang.bat";
179 $script = "./show-shebang";
182 $script = ":show-shebang";
185 $script = ":show-shebang";
187 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
189 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
193 $s1 = "\$^X is $perl, \$0 is $script\n";
194 ok open(SCRIPT, ">$script"), $!;
195 ok print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
198 print "\$^X is $^X, \$0 is $0\n";
200 ok close(SCRIPT), $!;
201 ok chmod(0755, $script), $!;
202 $_ = $Is_MacOS ? `$perl $script` : `$script`;
203 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
204 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
205 s{is perl}{is $perl}; # for systems where $^X is only a basename
207 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:");
208 $_ = `$perl $script`;
209 s/\.exe//i if $Is_Dos or $Is_os2;
211 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`");
212 ok unlink($script), $!;
216 ok $] >= 5.00319, $];
218 ok $^T > 850000000, $^T;
220 if ($Is_VMS || $Is_Dos || $Is_MacOS) {
225 $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0;
229 $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0;
230 ok ($Is_MSWin32 ? (`set foo 2>NUL` eq "")
231 : (`echo \$foo` eq "\n") );
233 $ENV{__NoNeSuCh} = "foo";
235 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
237 ok ($Is_MSWin32 ? (`set __NoNeSuCh` =~ /^(__NoNeSuCh=)?foo$/)
238 : (`echo \$__NoNeSuCh` eq "foo\n") );
242 local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
247 # test case-insignificance of %ENV (these tests must be enabled only
248 # when perl is compiled with -DENV_IS_CASELESS)
249 if ($Is_MSWin32 || $Is_NetWare) {
253 ok (scalar(keys(%ENV)) == 1);
254 ok exists($ENV{'FOo'});
255 ok (delete($ENV{'foO'}) eq 'baz');
256 ok (scalar(keys(%ENV)) == 0);
259 skip('no caseless %ENV support') for 1..4;
262 # Make sure Errno hasn't been prematurely autoloaded
264 ok !defined %Errno::;
266 # Test auto-loading of Errno when %! is used
274 # Make sure that Errno loading doesn't clobber $!
277 delete $INC{"Errno.pm"};
279 open(FOO, "nonesuch"); # Generate ENOENT
280 my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time
284 eval { ok $^S == 1 };