This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
[perl5.git] / dist / Exporter / t / warn.t
CommitLineData
0fe08b2b
TC
1#!perl -w
2
3# Can't use Test::Simple/More, they depend on Exporter.
4my $test;
5sub ok ($;$) {
6 my($ok, $name) = @_;
7
8 # You have to do it this way or VMS will get confused.
9 printf "%sok %d%s\n", ($ok ? '' : 'not '), $test,
10 (defined $name ? " - $name" : '');
11
12 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
13
14 $test++;
15 return $ok;
16}
17
18
19BEGIN {
20 $test = 1;
21 print "1..2\n";
22 require Exporter;
23 ok( 1, 'Exporter compiled' );
24}
25
26package Foo;
27Exporter->import("import");
28@EXPORT_OK = "bar";
29
30package main;
31
32{ # [perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
33 my @warn;
34
35 local $SIG{__WARN__} = sub { push @warn, join "", @_ };
36 eval { Foo->import(":quux") };
d7d11da6 37 ok(grep(/"quux" is not defined/, @warn), "warnings captured");
0fe08b2b
TC
38}
39