Commit | Line | Data |
0ca3a874 |
1 | BEGIN { |
0ca3a874 |
2 | push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS'; |
3 | require Config; import Config; |
4 | if ($Config{'extensions'} !~ /\bXS\/APItest\b/) { |
5 | print "1..0 # Skip: XS::APItest was not built\n"; |
6 | exit 0; |
7 | } |
8 | } |
9 | |
7e7a3dfc |
10 | use Test::More tests => 12; |
0ca3a874 |
11 | |
12 | BEGIN { use_ok('XS::APItest') }; |
13 | |
14 | ######################### |
15 | |
16 | my $rv; |
17 | |
18 | $XS::APItest::exception_caught = undef; |
19 | |
7a646707 |
20 | $rv = eval { apitest_exception(0) }; |
0ca3a874 |
21 | is($@, ''); |
22 | ok(defined $rv); |
23 | is($rv, 42); |
24 | is($XS::APItest::exception_caught, 0); |
25 | |
26 | $XS::APItest::exception_caught = undef; |
27 | |
7a646707 |
28 | $rv = eval { apitest_exception(1) }; |
0ca3a874 |
29 | is($@, "boo\n"); |
30 | ok(not defined $rv); |
31 | is($XS::APItest::exception_caught, 1); |
ef469b03 |
32 | |
7e7a3dfc |
33 | $rv = eval { mycroak("foobar\n"); 1 }; |
ef469b03 |
34 | is($@, "foobar\n", 'croak'); |
7e7a3dfc |
35 | ok(not defined $rv); |
36 | |
37 | $rv = eval { $@ = bless{}, "foo"; mycroak(undef); 1 }; |
38 | is(ref($@), "foo", 'croak(NULL)'); |
39 | ok(not defined $rv); |