summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorGisle Aas <gisle@activestate.com>2006-03-21 10:16:43 +0000
committerGisle Aas <gisle@activestate.com>2006-03-21 10:16:43 +0000
commit7e7a3dfc0d3c74b10a066568a904a5a10013d5e4 (patch)
treef2f7e43f001c50be6ef37712c685621a9861e814 /ext
parentffca234a07dfeae45b7c9ca966164446c5bc3d4b (diff)
downloadperl-7e7a3dfc0d3c74b10a066568a904a5a10013d5e4.tar.gz
Test croak(NULL)
p4raw-id: //depot/perl@27560
Diffstat (limited to 'ext')
-rw-r--r--ext/XS/APItest/APItest.xs11
-rw-r--r--ext/XS/APItest/t/exception.t9
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);