xref: /openbsd/gnu/usr.bin/perl/ext/XS-APItest/t/my_exit.t (revision d415bd75)
1#!perl
2
3use strict;
4use warnings;
5
6require "test.pl";
7
8plan(4);
9
10use XS::APItest;
11
12my ($prog, $expect) = (<<'PROG', <<'EXPECT');
13use XS::APItest;
14print "ok\n";
15my_exit(1);
16print "not\n";
17PROG
18ok
19EXPECT
20fresh_perl_is($prog, $expect);
21
22# C's EXIT_FAILURE ends up as SS$_ABORT (decimal 44) on VMS, which gets
23# shifted to 4.  Perl_my_exit (unlike Perl_my_failure_exit) does not
24# have access to the vmsish pragmas to modify that behavior.
25
26my $exit_failure = $^O eq 'VMS' ? 4 : 1;
27is($? >> 8, $exit_failure, "exit code plain my_exit");
28
29($prog, $expect) = (<<'PROG', <<'EXPECT');
30use XS::APItest;
31print "ok\n";
32call_sv( sub { my_exit(1); }, G_EVAL );
33print "not\n";
34PROG
35ok
36EXPECT
37fresh_perl_is($prog, $expect);
38is($? >> 8, $exit_failure, "exit code my_exit inside a call_sv with G_EVAL");
39
40