Retract #11530 (the dTHX is needed under threads)
[p5sagit/p5-mst-13.2.git] / t / run / exit.t
CommitLineData
14cf881c 1#!./perl
2#
3# Tests for perl exit codes, playing with $?, etc...
4
5
6BEGIN {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9}
10
ee2f883e 11# VMS and Windows need -e "...", most everything else works better with '
12my $quote = $^O =~ /^(VMS|MSWin\d+)$/ ? q{"} : q{'};
14cf881c 13
14# Run some code, return its wait status.
15sub run {
16 my($code) = shift;
17 my $cmd = "$^X -e ";
18 return system($cmd.$quote.$code.$quote);
19}
20
21use Test::More tests => 3;
22
23my $exit;
24
25$exit = run('exit');
26is( $exit >> 8, 0, 'Normal exit' );
27
28$exit = run('exit 42');
29is( $exit >> 8, 42, 'Non-zero exit' );
30
31$exit = run('END { $? = 42 }');
32is( $exit >> 8, 42, 'Changing $? in END block' );