This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
install libgdbm and libdb in GitHub Actions
[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");
dd07b881
TR
28our @EXPORT_OK = qw/bar/;
29
0fe08b2b
TC
30
31package main;
32
33{ # [perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
34 my @warn;
35
36 local $SIG{__WARN__} = sub { push @warn, join "", @_ };
37 eval { Foo->import(":quux") };
d7d11da6 38 ok(grep(/"quux" is not defined/, @warn), "warnings captured");
0fe08b2b
TC
39}
40