12 use Test::More tests => 50 * 6 + 2;
22 return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xyz_\$]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/
31 local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
33 eval "die qq{ok\\n}; use indirect; $_";
34 is($@, "ok\n", "use indirect: $_");
36 eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
37 like($@, expect('Hlagh'), "no indirect: $_");
41 eval "die qq{ok\\n}; use indirect; $_";
42 is($@, "ok\n", "use indirect, defined: $_");
44 eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
45 like($@, expect('Dongs'), "no indirect, defined: $_");
50 eval "die qq{ok\\n}; use indirect; $_";
51 is($@, "ok\n", "use indirect, spaces: $_");
53 eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
54 like($@, expect('Hlagh'), "no indirect, spaces: $_");
60 local $SIG{__WARN__} = sub { $warn = join ' ', @_ };
61 eval "die qq{ok\n}; no indirect 'hlagh'; \$obj = new Hlagh1;";
62 is($@, "ok\n", 'no indirect "hlagh" didn\'t croak');
63 like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh1"/, 'no indirect "hlagh" enables the pragma');
73 $obj = new Hlagh(1, 2);
77 $obj = new Hlagh ( ) ;
79 $obj = new Hlagh ( 1 ) ;
81 $obj = new Hlagh ( 1 , 2 ) ;
106 $obj = new $x('foo');
108 $obj = new $x qq{foo}, 1;
110 $obj = new $x qr{foo\s+bar}, 1 .. 1;
112 $obj = new $x(qw/bar baz/);
120 $obj = new $_ qr/foo/ ;
122 $obj = new $_ qq(bar baz);
152 meh $sploosh::sploosh;
170 meh $sploosh::sploosh;
176 new Hlagh->wut, "Wut";
178 $obj = HlaghHlagh Hlagh;
180 $obj = HlaghHlagh Hlagh; # HlaghHlagh Hlagh
184 $obj = new newnew; # new newnew