summaryrefslogtreecommitdiffstats
path: root/t/06-runtime.t
blob: 6e429b7abac58c08f4a9d21310c26e6f9fe0f5b2 (plain) (blame)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use lib 't/lib/06';

sub warnings_ok {
    my ($class, $expected) = @_;
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my $warnings;
    local $SIG{__WARN__} = sub { $warnings .= $_[0] };
    use_ok($class);
    is($warnings, $expected, "correct runtime warnings for $class");
}

warnings_ok('Foo', <<'WARNINGS');
Conflict detected for Foo::Conflicts:
  Foo::Foo is version 0.01, but must be greater than version 0.01
Conflict detected for Foo::Conflicts:
  Foo::Bar is version 0.01, but must be greater than version 0.01
WARNINGS
warnings_ok('Bar', <<'WARNINGS');
Conflict detected for Bar::Conflicts:
  Bar::Baz::Bad is version 0.01, but must be greater than version 0.01
Conflict detected for Bar::Conflicts:
  Bar::Foo::Bad is version 0.01, but must be greater than version 0.01
Conflict detected for Bar::Conflicts:
  Bar::Foo is version 0.01, but must be greater than version 0.01
Conflict detected for Bar::Conflicts:
  Bar::Bar::Bad is version 0.01, but must be greater than version 0.01
Conflict detected for Bar::Conflicts:
  Bar::Bar is version 0.01, but must be greater than version 0.01
Conflict detected for Bar::Conflicts:
  Bar::Quux::Bad is version 0.01, but must be greater than version 0.01
WARNINGS

is(scalar(grep { ref($_) eq 'ARRAY' && @$_ > 1 && ref($_->[1]) eq 'HASH' }
               @INC),
   1,
   "only installed one \@INC hook");

done_testing;