summaryrefslogtreecommitdiff
path: root/t/run/exit.t
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2001-06-29 15:39:11 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-30 12:59:25 +0000
commit14cf881c49354abdedb2f64b4fde446a92185e9f (patch)
treececb7efdc4a093382596df4804cbbc9e735c5446 /t/run/exit.t
parenta01268b57212e226e8cd71d448590f3e6c10d529 (diff)
downloadperl-14cf881c49354abdedb2f64b4fde446a92185e9f.tar.gz
Another shot at testing exit codes.
Message-ID: <20010629193910.D25304@blackrider> p4raw-id: //depot/perl@11039
Diffstat (limited to 't/run/exit.t')
-rw-r--r--t/run/exit.t32
1 files changed, 32 insertions, 0 deletions
diff --git a/t/run/exit.t b/t/run/exit.t
new file mode 100644
index 0000000000..828b83228a
--- /dev/null
+++ b/t/run/exit.t
@@ -0,0 +1,32 @@
+#!./perl
+#
+# Tests for perl exit codes, playing with $?, etc...
+
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+# VMS needs -e "...", most everything else works better with '
+my $quote = $^O eq 'VMS' ? q{"} : q{'};
+
+# Run some code, return its wait status.
+sub run {
+ my($code) = shift;
+ my $cmd = "$^X -e ";
+ return system($cmd.$quote.$code.$quote);
+}
+
+use Test::More tests => 3;
+
+my $exit;
+
+$exit = run('exit');
+is( $exit >> 8, 0, 'Normal exit' );
+
+$exit = run('exit 42');
+is( $exit >> 8, 42, 'Non-zero exit' );
+
+$exit = run('END { $? = 42 }');
+is( $exit >> 8, 42, 'Changing $? in END block' );