Change 27560 by [EMAIL PROTECTED] on 2006/03/21 10:16:43
Test croak(NULL)
Affected files ...
... //depot/perl/ext/XS/APItest/APItest.xs#26 edit
... //depot/perl/ext/XS/APItest/t/exception.t#3 edit
Differences ...
==== //depot/perl/ext/XS/APItest/APItest.xs#26 (text) ====
Index: perl/ext/XS/APItest/APItest.xs
--- perl/ext/XS/APItest/APItest.xs#25~27000~ 2006-01-30 04:59:12.000000000
-0800
+++ perl/ext/XS/APItest/APItest.xs 2006-03-21 02:16:43.000000000 -0800
@@ -461,10 +461,15 @@
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()
==== //depot/perl/ext/XS/APItest/t/exception.t#3 (text) ====
Index: perl/ext/XS/APItest/t/exception.t
--- perl/ext/XS/APItest/t/exception.t#2~24533~ 2005-05-21 12:50:50.000000000
-0700
+++ perl/ext/XS/APItest/t/exception.t 2006-03-21 02:16:43.000000000 -0800
@@ -9,7 +9,7 @@
}
}
-use Test::More tests => 9;
+use Test::More tests => 12;
BEGIN { use_ok('XS::APItest') };
@@ -32,5 +32,10 @@
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);
End of Patch.