File: 22-warnings-bareword.t

package info (click to toggle)
libtest-warnings-perl 0.038-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 472 kB
  • sloc: perl: 375; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;

use Test::More 0.88;
use Test::Warnings ':no_end_test', 'warnings';

my $e;
my $no_warn_sub;
my $warn_sub;
{
    no warnings;
    if (!eval q{
        $no_warn_sub = sub { return 1 + undef };
        BEGIN { warnings->import }
        $warn_sub = sub { return 1 + undef };
        1;
    }) {
        $e = $@;
    }
}

is $e, undef,
    'warnings->import succeeds after importing "warnings" sub';

ok !warnings { $no_warn_sub->() },
    'no warnings worked as expected';

like +(warnings { $warn_sub->() })[0], qr{uninitialized value},
    'correct warnings were enabled after warnings->import';

done_testing;