| 1 |
use Test::More tests => 12; |
| 2 |
|
| 3 |
BEGIN { use_ok('XS::APItest') }; |
| 4 |
|
| 5 |
######################### |
| 6 |
|
| 7 |
my $rv; |
| 8 |
|
| 9 |
$XS::APItest::exception_caught = undef; |
| 10 |
|
| 11 |
$rv = eval { apitest_exception(0) }; |
| 12 |
is($@, ''); |
| 13 |
ok(defined $rv); |
| 14 |
is($rv, 42); |
| 15 |
is($XS::APItest::exception_caught, 0); |
| 16 |
|
| 17 |
$XS::APItest::exception_caught = undef; |
| 18 |
|
| 19 |
$rv = eval { apitest_exception(1) }; |
| 20 |
is($@, "boo\n"); |
| 21 |
ok(not defined $rv); |
| 22 |
is($XS::APItest::exception_caught, 1); |
| 23 |
|
| 24 |
$rv = eval { mycroak("foobar\n"); 1 }; |
| 25 |
is($@, "foobar\n", 'croak'); |
| 26 |
ok(not defined $rv); |
| 27 |
|
| 28 |
$rv = eval { $@ = bless{}, "foo"; mycroak(undef); 1 }; |
| 29 |
is(ref($@), "foo", 'croak(NULL)'); |
| 30 |
ok(not defined $rv); |