diff options
-rw-r--r-- | ext/XS/APItest/APItest.xs | 11 | ||||
-rw-r--r-- | ext/XS/APItest/t/exception.t | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/ext/XS/APItest/APItest.xs b/ext/XS/APItest/APItest.xs index c8391c6bf2..3a31ec9801 100644 --- a/ext/XS/APItest/APItest.xs +++ b/ext/XS/APItest/APItest.xs @@ -461,10 +461,15 @@ exception(throw_e) RETVAL void -mycroak(pv) - const char* pv +mycroak(sv) + SV* sv CODE: - Perl_croak(aTHX_ "%s", pv); + if (SvOK(sv)) { + Perl_croak(aTHX_ "%s", SvPV_nolen(sv)); + } + else { + Perl_croak(aTHX_ NULL); + } SV* strtab() diff --git a/ext/XS/APItest/t/exception.t b/ext/XS/APItest/t/exception.t index 53415893fe..dc6d3246d6 100644 --- a/ext/XS/APItest/t/exception.t +++ b/ext/XS/APItest/t/exception.t @@ -9,7 +9,7 @@ BEGIN { } } -use Test::More tests => 9; +use Test::More tests => 12; BEGIN { use_ok('XS::APItest') }; @@ -32,5 +32,10 @@ is($@, "boo\n"); ok(not defined $rv); is($XS::APItest::exception_caught, 1); -$rv = eval { mycroak("foobar\n") }; +$rv = eval { mycroak("foobar\n"); 1 }; is($@, "foobar\n", 'croak'); +ok(not defined $rv); + +$rv = eval { $@ = bless{}, "foo"; mycroak(undef); 1 }; +is(ref($@), "foo", 'croak(NULL)'); +ok(not defined $rv); |