3 # $RCSfile: magic.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:05 $
10 $SIG{__WARN__} = sub { die @_ };
14 my ($n, $result, $info) = @_;
20 print "# $info\n" if $info;
26 eval '$ENV{"foo"} = "hi there";'; # check that ENV is inited inside eval
27 ok 1, `echo \$foo` eq "hi there\n";
29 unlink 'ajslkdfpqjsjfk';
31 open(FOO,'ajslkdfpqjsjfk');
33 close FOO; # just mention it, squelch used-only-once
35 # the next tests are embedded inside system simply because sh spits out
36 # a newline onto stderr when a child process kills itself with SIGINT.
38 system './perl', '-e', <<'END';
40 $| = 1; # command buffering
42 $SIG{"INT"} = "ok3"; kill "INT",$$;
43 $SIG{"INT"} = "IGNORE"; kill 2,$$; print "ok 4\n";
44 $SIG{"INT"} = "DEFAULT"; kill 2,$$; print "not ok\n";
47 if (($x = pop(@_)) eq "INT") {
51 print "not ok 3 ($x @_)\n";
57 @val1 = @ENV{keys(%ENV)}; # can we slice ENV?
59 ok 5, join(':',@val1) eq join(':',@val2);
63 'foobarbaz' =~ /b(a)r/;
64 ok 7, $` eq 'foo', $`;
65 ok 8, $& eq 'bar', $&;
66 ok 9, $' eq 'baz', $';
71 ok 11, "@a" eq "foo bar baz", "@a";
74 ok 12, "@a" eq "foo,bar,baz", "@a";
80 ok 13, (keys %h)[0] eq "foo\034bar", (keys %h)[0];
85 ok 14, (keys %h)[0] eq 'fooxbar', (keys %h)[0];
95 ok 17, $@ eq "foo\n", $@;
100 $script = './show-shebang';
101 ok 19, open(SCRIPT, ">$script"), $!;
102 ok 20, print(SCRIPT <<'EOF'), $!;
104 print "\$^X is $^X, \$0 is $0\n";
106 ok 21, close(SCRIPT), $!;
107 ok 22, chmod(0755, $script), $!;
108 $s = "\$^X is ./perl, \$0 is $script\n";
110 ok 23, $_ eq $s, ":$_:";
111 $_ = `./perl $script`;
112 ok 24, $_ eq $s, ":$_:";
113 ok 25, unlink($script), $!;
116 ok 26, $] >= 5.00319, $];
118 ok 28, $^T > 850000000, $^T;