ext/XS-APItest/t/call_checker.t test call checker plugin API
ext/XS-APItest/t/caller.t XS::APItest: tests for caller_cx
ext/XS-APItest/t/call.t XS::APItest extension
+ext/XS-APItest/t/check_warnings.t test scope of "Too late for CHECK"
ext/XS-APItest/t/cleanup.t test stack behaviour on unwinding
ext/XS-APItest/t/clone-with-stack.t test clone with CLONEf_COPY_STACKS works
ext/XS-APItest/t/cophh.t test COPHH API
--- /dev/null
+#!perl
+
+# This test checks to make sure that a BEGIN block created from an XS call
+# does not implicitly change the current warning scope, causing a CHECK
+# or INIT block created after the corresponding phase to warn when it
+# shouldn’t.
+
+use Test::More tests => 1;
+
+$SIG{__WARN__} = sub { $w .= shift };
+
+use warnings;
+eval q|
+ BEGIN{
+ no warnings;
+ package XS::APItest; require XSLoader; XSLoader::load()
+ }
+|;
+
+is $w, undef, 'No warnings about CHECK and INIT in warningless scope';
@trap = sort @trap;
is(scalar @trap, 2, "There were 2 warnings");
- is($trap[0], "Too late to run CHECK block.\n");
- is($trap[1], "Too late to run INIT block.\n");
+ like($trap[0], qr "^Too late to run CHECK block");
+ like($trap[1], qr "^Too late to run INIT block");
}
print "# Second body\n";
ENTER;
SAVECOPFILE(&PL_compiling);
SAVECOPLINE(&PL_compiling);
+ SAVEVPTR(PL_curcop);
DEBUG_x( dump_sub(gv) );
Perl_av_create_and_push(aTHX_ &PL_beginav, MUTABLE_SV(cv));
GvCV_set(gv,0); /* cv has been hijacked */
call_list(oldscope, PL_beginav);
- PL_curcop = &PL_compiling;
CopHINTS_set(&PL_compiling, PL_hints);
LEAVE;
}