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