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 if ($Is_MSWin32) { ok 1, `set FOO` eq "FOO=hi there\n"; }
36 else { ok 1, `echo \$FOO` eq "hi there\n"; }
38 unlink 'ajslkdfpqjsjfk';
40 open(FOO,'ajslkdfpqjsjfk');
42 close FOO; # just mention it, squelch used-only-once
44 if ($Is_MSWin32 || $Is_NetWare || $Is_Dos || $Is_MPE) {
49 # the next tests are embedded inside system simply because sh spits out
50 # a newline onto stderr when a child process kills itself with SIGINT.
51 system './perl', '-e', <<'END';
53 $| = 1; # command buffering
55 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
56 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
57 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok\n";
60 if (($x = pop(@_)) eq "INT") {
64 print "not ok 3 ($x @_)\n";
72 @val1 = @ENV{keys(%ENV)};
74 ok 5, join(':',@val1) eq join(':',@val2);
78 'foobarbaz' =~ /b(a)r/;
79 ok 7, $` eq 'foo', $`;
80 ok 8, $& eq 'bar', $&;
81 ok 9, $' eq 'baz', $';
86 ok 11, "@a" eq "foo bar baz", "@a";
89 ok 12, "@a" eq "foo,bar,baz", "@a";
95 ok 13, (keys %h)[0] eq "foo\034bar", (keys %h)[0];
100 ok 14, (keys %h)[0] eq 'fooxbar', (keys %h)[0];
104 system qq[$PERL -e "exit(0)"];
106 system qq[$PERL -e "exit(1)"];
109 eval { die "foo\n" };
110 ok 17, $@ eq "foo\n", $@;
117 chomp($wd = `/usr/bin/fullpath -t`);
120 # Cygwin turns the symlink into the real file
125 $wd = Cwd::sys_cwd();
130 my $perl = "$wd/perl";
133 $script = "$wd/show-shebang";
137 $perl = "$wd/perl.exe";
138 $script = "$wd/show-shebang.bat";
153 $script = "./show-shebang";
155 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
157 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
161 $s1 = "\$^X is $perl, \$0 is $script\n";
162 ok 19, open(SCRIPT, ">$script"), $!;
163 ok 20, print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
166 print "\$^X is $^X, \$0 is $0\n";
168 ok 21, close(SCRIPT), $!;
169 ok 22, chmod(0755, $script), $!;
171 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
172 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
173 s{is perl}{is $perl}; # for systems where $^X is only a basename
175 ok 23, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:";
176 $_ = `$perl $script`;
177 s/\.exe//i if $Is_Dos or $Is_os2;
179 ok 24, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`";
180 ok 25, unlink($script), $!;
184 ok 26, $] >= 5.00319, $];
186 ok 28, $^T > 850000000, $^T;
188 if ($Is_VMS || $Is_Dos) {
189 ok "29 # skipped", 1;
190 ok "30 # skipped", 1;
194 $PDL = $ENV{PERL_DESTRUCT_LEVEL} || 0;
198 $ENV{PERL_DESTRUCT_LEVEL} = $PDL || 0;
199 ok 29, ($Is_MSWin32 ? (`set foo 2>NUL` eq "")
200 : (`echo \$foo` eq "\n") );
202 $ENV{__NoNeSuCh} = "foo";
204 ok 30, ($Is_MSWin32 ? (`set __NoNeSuCh` eq "__NoNeSuCh=foo\n")
205 : (`echo \$__NoNeSuCh` eq "foo\n") );
209 local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
214 # test case-insignificance of %ENV (these tests must be enabled only
215 # when perl is compiled with -DENV_IS_CASELESS)
216 if ($Is_MSWin32 || $Is_NetWare) {
220 ok 32, (scalar(keys(%ENV)) == 1);
221 ok 33, exists($ENV{'FOo'});
222 ok 34, (delete($ENV{'foO'}) eq 'baz');
223 ok 35, (scalar(keys(%ENV)) == 0);
226 ok "32 # skipped: no caseless %ENV support",1;
227 ok "33 # skipped: no caseless %ENV support",1;
228 ok "34 # skipped: no caseless %ENV support",1;
229 ok "35 # skipped: no caseless %ENV support",1;
232 # Make sure Errno hasn't been prematurely autoloaded
234 ok 36, !defined %Errno::;
236 # Test auto-loading of Errno when %! is used
238 ok 37, scalar eval q{
244 # Make sure that Errno loading doesn't clobber $!
247 delete $INC{"Errno.pm"};
249 open(FOO, "nonesuch"); # Generate ENOENT
250 my %errs = %{"!"}; # Cause Errno.pm to be loaded at run-time
251 ok 38, ${"!"}{ENOENT};
254 eval { ok 40, $^S == 1 };