]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/22-bad-mixed.t
Fix a rare edge case for package whose names are prefix of 'main'
[perl/modules/indirect.git] / t / 22-bad-mixed.t
1 #!perl -T
2
3 package Dongs;
4
5 sub new;
6
7 package main;
8
9 use strict;
10 use warnings;
11
12 use Test::More tests => 3 * 4;
13
14 sub meh;
15
16 {
17  local $/ = "####\n";
18  while (<DATA>) {
19   chomp;
20   s/\s*$//;
21   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
22   {
23    use indirect;
24    eval "die qq{ok\\n}; $_";
25   }
26   is($@, "ok\n", "use indirect: $_");
27   {
28    no indirect;
29    eval "die qq{ok\n}; $_";
30   }
31   is($@, "ok\n", "no indirect: $_");
32   s/Hlagh/Dongs/g;
33   {
34    use indirect;
35    eval "die qq{ok\\n}; $_";
36   }
37   is($@, "ok\n", "use indirect, defined: $_");
38   {
39    no indirect;
40    eval "die qq{the code compiled but it shouldn't have\n}; $_";
41   }
42   like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
43  }
44 }
45
46 __DATA__
47 meh Hlagh->new;
48 ####
49 meh Hlagh->new();
50 ####
51 meh Hlagh->new, "Wut";