Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
79072805 | 3 | # $RCSfile: magic.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:05 $ |
8d063cd8 LW |
4 | |
5 | $| = 1; # command buffering | |
6 | ||
a687059c | 7 | print "1..5\n"; |
378cc40b LW |
8 | |
9 | eval '$ENV{"foo"} = "hi there";'; # check that ENV is inited inside eval | |
8d063cd8 LW |
10 | if (`echo \$foo` eq "hi there\n") {print "ok 1\n";} else {print "not ok 1\n";} |
11 | ||
bf38876a | 12 | unlink 'ajslkdfpqjsjfk'; |
8d063cd8 | 13 | $! = 0; |
bf38876a | 14 | open(foo,'ajslkdfpqjsjfk'); |
8d063cd8 LW |
15 | if ($! == 2) {print "ok 2\n";} else {print "not ok 2\n";} |
16 | ||
378cc40b LW |
17 | # the next tests are embedded inside system simply because sh spits out |
18 | # a newline onto stderr when a child process kills itself with SIGINT. | |
19 | ||
79072805 | 20 | system './perl', '-e', <<'END'; |
378cc40b | 21 | |
79072805 | 22 | $| = 1; # command buffering |
378cc40b | 23 | |
79072805 LW |
24 | $SIG{"INT"} = "ok3"; kill "INT",$$; |
25 | $SIG{"INT"} = "IGNORE"; kill 2,$$; print "ok 4\n"; | |
26 | $SIG{"INT"} = "DEFAULT"; kill 2,$$; print "not ok\n"; | |
27 | ||
28 | sub ok3 { | |
29 | if (($x = pop(@_)) eq "INT") { | |
30 | print "ok 3\n"; | |
31 | } | |
32 | else { | |
33 | print "not ok 3 $a\n"; | |
34 | } | |
35 | } | |
36 | ||
37 | END | |
a687059c LW |
38 | |
39 | @val1 = @ENV{keys(%ENV)}; # can we slice ENV? | |
40 | @val2 = values(%ENV); | |
41 | ||
42 | print join(':',@val1) eq join(':',@val2) ? "ok 5\n" : "not ok 5\n"; |