Commit | Line | Data |
14cf881c |
1 | #!./perl |
2 | # |
3 | # Tests for perl exit codes, playing with $?, etc... |
4 | |
5 | |
6 | BEGIN { |
7 | chdir 't' if -d 't'; |
8 | @INC = '../lib'; |
9 | } |
10 | |
11 | # VMS needs -e "...", most everything else works better with ' |
12 | my $quote = $^O eq 'VMS' ? q{"} : q{'}; |
13 | |
14 | # Run some code, return its wait status. |
15 | sub run { |
16 | my($code) = shift; |
17 | my $cmd = "$^X -e "; |
18 | return system($cmd.$quote.$code.$quote); |
19 | } |
20 | |
21 | use Test::More tests => 3; |
22 | |
23 | my $exit; |
24 | |
25 | $exit = run('exit'); |
26 | is( $exit >> 8, 0, 'Normal exit' ); |
27 | |
28 | $exit = run('exit 42'); |
29 | is( $exit >> 8, 42, 'Non-zero exit' ); |
30 | |
31 | $exit = run('END { $? = 42 }'); |
32 | is( $exit >> 8, 42, 'Changing $? in END block' ); |