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()
}
}
-use Test::More tests => 9;
+use Test::More tests => 12;
BEGIN { use_ok('XS::APItest') };
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);