summaryrefslogtreecommitdiff
path: root/dist/Exporter/t/warn.t
blob: 30109644b90590cae4b81211ebbe7b80ab00296c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl -w

# Can't use Test::Simple/More, they depend on Exporter.
my $test;
sub ok ($;$) {
    my($ok, $name) = @_;

    # You have to do it this way or VMS will get confused.
    printf "%sok %d%s\n", ($ok ? '' : 'not '), $test,
      (defined $name ? " - $name" : '');

    printf "# Failed test at line %d\n", (caller)[2] unless $ok;

    $test++;
    return $ok;
}


BEGIN {
    $test = 1;
    print "1..2\n";
    require Exporter;
    ok( 1, 'Exporter compiled' );
}

package Foo;
Exporter->import("import");
@EXPORT_OK = "bar";

package main;

{ # [perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
    my @warn;

    local $SIG{__WARN__} = sub { push @warn, join "", @_ };
    eval { Foo->import(":quux") };
    ok(grep(/"quux" is not defined/, @warn), "warnings captured");
}