File: n0_die_on_error.t

package info (click to toggle)
libmodule-info-perl 0.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 2,202; makefile: 8
file content (45 lines) | stat: -rw-r--r-- 1,070 bytes parent folder | download
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
40
41
42
43
44
45
#!/usr/bin/perl -w

use strict;
use lib './t/lib';
use Test::More tests => 4;
use lib '.';
use Module::Info;

my $baz = Module::Info->new_from_module( 'Baz' );
my $bar = Module::Info->new_from_module( 'Foo' );

SKIP: {
    skip "Only works on 5.6.1 and up.", 4 unless $] >= 5.006001;

    # Bar.pm should compile correctly
    $bar->die_on_compilation_error(1);
    eval {
        $bar->packages_inside;
    };
    ok( !$@, "does not die if compilation is ok" );
    diag( $@ ) if $@;

    {
        # suppress warning message
        local $SIG{__WARN__} = sub { };

        eval {
            $baz->packages_inside;
        };
        ok( !$@, "does not die unless die_on_compilation_error is set" );
        diag( $@ ) if $@;
    }

    {
        my $did_warn;
        local $SIG{__WARN__} = sub { $did_warn = 1 };
        $baz->die_on_compilation_error(1);

        eval {
            $baz->packages_inside;
        };
        ok( $@, "dies if die_on_compilation_error is set" );
        ok( !$did_warn, "does not warn if die_on_compilation_error is set" );
    }
}