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_VMS = $^O eq 'VMS';
25 $Is_Dos = $^O eq 'dos';
26 $Is_os2 = $^O eq 'os2';
27 $Is_Cygwin = $^O eq 'cygwin';
28 $PERL = ($Is_MSWin32 ? '.\perl' : './perl');
32 eval '$ENV{"FOO"} = "hi there";'; # check that ENV is inited inside eval
33 if ($Is_MSWin32) { ok 1, `cmd /x /c set FOO` eq "FOO=hi there\n"; }
34 else { ok 1, `echo \$FOO` eq "hi there\n"; }
36 unlink 'ajslkdfpqjsjfk';
38 open(FOO,'ajslkdfpqjsjfk');
40 close FOO; # just mention it, squelch used-only-once
42 if ($Is_MSWin32 || $Is_Dos) {
47 # the next tests are embedded inside system simply because sh spits out
48 # a newline onto stderr when a child process kills itself with SIGINT.
49 system './perl', '-e', <<'END';
51 $| = 1; # command buffering
53 $SIG{"INT"} = "ok3"; kill "INT",$$; sleep 1;
54 $SIG{"INT"} = "IGNORE"; kill "INT",$$; sleep 1; print "ok 4\n";
55 $SIG{"INT"} = "DEFAULT"; kill "INT",$$; sleep 1; print "not ok\n";
58 if (($x = pop(@_)) eq "INT") {
62 print "not ok 3 ($x @_)\n";
70 @val1 = @ENV{keys(%ENV)};
72 ok 5, join(':',@val1) eq join(':',@val2);
76 'foobarbaz' =~ /b(a)r/;
77 ok 7, $` eq 'foo', $`;
78 ok 8, $& eq 'bar', $&;
79 ok 9, $' eq 'baz', $';
84 ok 11, "@a" eq "foo bar baz", "@a";
87 ok 12, "@a" eq "foo,bar,baz", "@a";
93 ok 13, (keys %h)[0] eq "foo\034bar", (keys %h)[0];
98 ok 14, (keys %h)[0] eq 'fooxbar', (keys %h)[0];
102 system qq[$PERL -e "exit(0)"];
104 system qq[$PERL -e "exit(1)"];
107 eval { die "foo\n" };
108 ok 17, $@ eq "foo\n", $@;
115 chomp($wd = `/usr/bin/fullpath -t`);
118 # Cygwin turns the symlink into the real file
123 $wd = Cwd::sys_cwd();
128 my $perl = "$wd/perl";
131 $script = "$wd/show-shebang";
135 $perl = "$wd/perl.exe";
136 $script = "$wd/show-shebang.bat";
151 $script = "./show-shebang";
153 if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
155 eval 'exec ./perl -S \$0 \${1+"\$\@"}'
159 $s1 = "\$^X is $perl, \$0 is $script\n";
160 ok 19, open(SCRIPT, ">$script"), $!;
161 ok 20, print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
164 print "\$^X is $^X, \$0 is $0\n";
166 ok 21, close(SCRIPT), $!;
167 ok 22, chmod(0755, $script), $!;
169 s/\.exe//i if $Is_Dos or $Is_Cygwin or $Is_os2;
170 s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
171 s{is perl}{is $perl}; # for systems where $^X is only a basename
173 ok 23, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1:";
174 $_ = `$perl $script`;
175 s/\.exe//i if $Is_Dos or $Is_os2;
177 ok 24, (($Is_MSWin32 || $Is_os2) ? uc($_) eq uc($s1) : $_ eq $s1), " :$_:!=:$s1: after `$perl $script`";
178 ok 25, unlink($script), $!;
182 ok 26, $] >= 5.00319, $];
184 ok 28, $^T > 850000000, $^T;
186 if ($Is_VMS || $Is_Dos) {
187 ok "29 # skipped", 1;
188 ok "30 # skipped", 1;
195 ok 29, ($Is_MSWin32 ? (`cmd /x /c set foo 2>NUL` eq "")
196 : (`echo \$foo` eq "\n") );
198 $ENV{__NoNeSuCh} = "foo";
200 ok 30, ($Is_MSWin32 ? (`cmd /x /c set __NoNeSuCh` eq "__NoNeSuCh=foo\n")
201 : (`echo \$__NoNeSuCh` eq "foo\n") );
205 local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
210 # test case-insignificance of %ENV (these tests must be enabled only
211 # when perl is compiled with -DENV_IS_CASELESS)
216 ok 32, (scalar(keys(%ENV)) == 1);
217 ok 33, exists($ENV{'FOo'});
218 ok 34, (delete($ENV{'foO'}) eq 'baz');
219 ok 35, (scalar(keys(%ENV)) == 0);
222 ok "32 # skipped: no caseless %ENV support",1;
223 ok "33 # skipped: no caseless %ENV support",1;
224 ok "34 # skipped: no caseless %ENV support",1;
225 ok "35 # skipped: no caseless %ENV support",1;