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" : '';
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_MPE = $^O eq 'mpeix';
48 $PERL = ($Is_MSWin32 ? '.\perl' : ($Is_NetWare ? 'perl' : './perl'));
50 eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
51 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
53 if ($Is_MSWin32) { ok `set FOO` =~ /^(FOO=)?hi there$/; }
54 else { ok `echo \$FOO` eq "hi there\n"; }
56 unlink 'ajslkdfpqjsjfk';
58 open(FOO,'ajslkdfpqjsjfk');
60 close FOO; # just mention it, squelch used-only-once
62 if ($Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE) {
66 # the next tests are embedded inside system simply because sh spits out
67 # a newline onto stderr when a child process kills itself with SIGINT.
68 system './perl', '-e', <<'END';
70 $| = 1; # command buffering
72 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
73 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
74 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok 4\n";
77 if (($x = pop(@_)) eq "INT") {
81 print "not ok 3 ($x @_)\n";
90 @val1 = @ENV{keys(%ENV)};
92 ok join(':',@val1) eq join(':',@val2);
96 'foobarbaz' =~ /b(a)r/;
103 @a = qw(foo bar baz);
104 ok "@a" eq "foo bar baz", "@a";
107 ok "@a" eq "foo,bar,baz", "@a";
112 $h{'foo', 'bar'} = 1;
113 ok((keys %h)[0] eq "foo\034bar", (keys %h)[0]);
117 $h{'foo', 'bar'} = 1;
118 ok((keys %h)[0] eq 'fooxbar', (keys %h)[0]);
122 system qq[$PERL -e "exit(0)"];
124 system qq[$PERL -e "exit(1)"];
127 eval { die "foo\n" };
128 ok $@ eq "foo\n", $@;
135 chomp($wd = `/usr/bin/fullpath -t`);
138 # Cygwin turns the symlink into the real file
143 $wd = Cwd::sys_cwd();
148 my $perl = "$wd/perl";
151 $script = "$wd/show-shebang";
155 $perl = "$wd/perl.exe";
156 $script = "$wd/show-shebang.bat";
171 $script = "./show-shebang";
173 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
175 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
179 $s1 = "\$^X is $perl, \$0 is $script\n";
180 ok open(SCRIPT, ">$script"), $!;
181 ok print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
184 print "\$^X is $^X, \$0 is $0\n";
186 ok close(SCRIPT), $!;
187 ok chmod(0755, $script), $!;
189 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
190 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
191 s{is perl}{is $perl}; # for systems where $^X is only a basename
193 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:");
194 $_ = `$perl $script`;
195 s/\.exe//i if $Is_Dos or $Is_os2;
197 ok((($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`");
198 ok unlink($script), $!;
202 ok $] >= 5.00319, $];
204 ok $^T > 850000000, $^T;
206 if ($Is_VMS || $Is_Dos) {
211 $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0;
215 $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0;
216 ok ($Is_MSWin32 ? (`set foo 2>NUL` eq "")
217 : (`echo \$foo` eq "\n") );
219 $ENV{__NoNeSuCh} = "foo";
221 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
223 ok ($Is_MSWin32 ? (`set __NoNeSuCh` =~ /^(__NoNeSuCh=)?foo$/)
224 : (`echo \$__NoNeSuCh` eq "foo\n") );
228 local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
233 # test case-insignificance of %ENV (these tests must be enabled only
234 # when perl is compiled with -DENV_IS_CASELESS)
235 if ($Is_MSWin32 || $Is_NetWare) {
239 ok (scalar(keys(%ENV)) == 1);
240 ok exists($ENV{'FOo'});
241 ok (delete($ENV{'foO'}) eq 'baz');
242 ok (scalar(keys(%ENV)) == 0);
245 skip('no caseless %ENV support') for 1..4;
248 # Make sure Errno hasn't been prematurely autoloaded
250 ok !defined %Errno::;
252 # Test auto-loading of Errno when %! is used
260 # Make sure that Errno loading doesn't clobber $!
263 delete $INC{"Errno.pm"};
265 open(FOO, "nonesuch"); # Generate ENOENT
266 my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time
270 eval { ok $^S == 1 };