7 $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
13 my ($n, $result, $info) = @_;
19 print "# $info\n" if $info;
23 $Is_MSWin32 = $^O eq 'MSWin32';
24 $Is_NetWare = $^O eq 'NetWare';
25 $Is_VMS = $^O eq 'VMS';
26 $Is_Dos = $^O eq 'dos';
27 $Is_os2 = $^O eq 'os2';
28 $Is_Cygwin = $^O eq 'cygwin';
29 $Is_MPE = $^O eq 'mpeix';
30 $PERL = ($Is_MSWin32 ? '.\perl' : ($Is_NetWare ? 'perl' : './perl'));
34 eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
35 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
37 if ($Is_MSWin32) { ok 1, `set FOO` =~ /^(FOO=)?hi there$/; }
38 else { ok 1, `echo \$FOO` eq "hi there\n"; }
40 unlink 'ajslkdfpqjsjfk';
42 open(FOO,'ajslkdfpqjsjfk');
44 close FOO; # just mention it, squelch used-only-once
46 if ($Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE) {
51 # the next tests are embedded inside system simply because sh spits out
52 # a newline onto stderr when a child process kills itself with SIGINT.
53 system './perl', '-e', <<'END';
55 $| = 1; # command buffering
57 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
58 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
59 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok\n";
62 if (($x = pop(@_)) eq "INT") {
66 print "not ok 3 ($x @_)\n";
74 @val1 = @ENV{keys(%ENV)};
76 ok 5, join(':',@val1) eq join(':',@val2);
80 'foobarbaz' =~ /b(a)r/;
81 ok 7, $` eq 'foo', $`;
82 ok 8, $& eq 'bar', $&;
83 ok 9, $' eq 'baz', $';
88 ok 11, "@a" eq "foo bar baz", "@a";
91 ok 12, "@a" eq "foo,bar,baz", "@a";
97 ok 13, (keys %h)[0] eq "foo\034bar", (keys %h)[0];
101 $h{'foo', 'bar'} = 1;
102 ok 14, (keys %h)[0] eq 'fooxbar', (keys %h)[0];
106 system qq[$PERL -e "exit(0)"];
108 system qq[$PERL -e "exit(1)"];
111 eval { die "foo\n" };
112 ok 17, $@ eq "foo\n", $@;
119 chomp($wd = `/usr/bin/fullpath -t`);
122 # Cygwin turns the symlink into the real file
127 $wd = Cwd::sys_cwd();
132 my $perl = "$wd/perl";
135 $script = "$wd/show-shebang";
139 $perl = "$wd/perl.exe";
140 $script = "$wd/show-shebang.bat";
155 $script = "./show-shebang";
157 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
159 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
163 $s1 = "\$^X is $perl, \$0 is $script\n";
164 ok 19, open(SCRIPT, ">$script"), $!;
165 ok 20, print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
168 print "\$^X is $^X, \$0 is $0\n";
170 ok 21, close(SCRIPT), $!;
171 ok 22, chmod(0755, $script), $!;
173 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
174 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
175 s{is perl}{is $perl}; # for systems where $^X is only a basename
177 ok 23, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:";
178 $_ = `$perl $script`;
179 s/\.exe//i if $Is_Dos or $Is_os2;
181 ok 24, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`";
182 ok 25, unlink($script), $!;
186 ok 26, $] >= 5.00319, $];
188 ok 28, $^T > 850000000, $^T;
190 if ($Is_VMS || $Is_Dos) {
191 ok "29 # skipped", 1;
192 ok "30 # skipped", 1;
196 $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0;
200 $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0;
201 ok 29, ($Is_MSWin32 ? (`set foo 2>NUL` eq "")
202 : (`echo \$foo` eq "\n") );
204 $ENV{__NoNeSuCh} = "foo";
206 # cmd.exe will echo 'variable=value' but 4nt will echo just the value
208 ok 30, ($Is_MSWin32 ? (`set __NoNeSuCh` =~ /^(__NoNeSuCh=)?foo$/)
209 : (`echo \$__NoNeSuCh` eq "foo\n") );
213 local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
218 # test case-insignificance of %ENV (these tests must be enabled only
219 # when perl is compiled with -DENV_IS_CASELESS)
220 if ($Is_MSWin32 || $Is_NetWare) {
224 ok 32, (scalar(keys(%ENV)) == 1);
225 ok 33, exists($ENV{'FOo'});
226 ok 34, (delete($ENV{'foO'}) eq 'baz');
227 ok 35, (scalar(keys(%ENV)) == 0);
230 ok "32 # skipped: no caseless %ENV support",1;
231 ok "33 # skipped: no caseless %ENV support",1;
232 ok "34 # skipped: no caseless %ENV support",1;
233 ok "35 # skipped: no caseless %ENV support",1;
236 # Make sure Errno hasn't been prematurely autoloaded
238 ok 36, !defined %Errno::;
240 # Test auto-loading of Errno when %! is used
242 ok 37, scalar eval q{
248 # Make sure that Errno loading doesn't clobber $!
251 delete $INC{"Errno.pm"};
253 open(FOO, "nonesuch"); # Generate ENOENT
254 my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time
255 ok 38, ${"!"}{ENOENT};
258 eval { ok 40, $^S == 1 };