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))"/
30 local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
33 eval "die qq{ok\\n}; $_";
35 is($@, "ok\n", "use indirect: $_");
38 eval "die qq{the code compiled but it shouldn't have\n}; $_";
40 like($@, expect('Hlagh'), "no indirect: $_");
44 eval "die qq{ok\\n}; $_";
46 is($@, "ok\n", "use indirect, defined: $_");
49 eval "die qq{the code compiled but it shouldn't have\n}; $_";
51 like($@, expect('Dongs'), "no indirect, defined: $_");
56 eval "die qq{ok\\n}; $_";
58 is($@, "ok\n", "use indirect, spaces: $_");
61 eval "die qq{the code compiled but it shouldn't have\n}; $_";
63 like($@, expect('Hlagh'), "no indirect, spaces: $_");
70 local $SIG{__WARN__} = sub { $warn = join ' ', @_ };
71 eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh1;";
72 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 eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh2;";
74 like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh2"/, 'no indirect "hlagh" doesn\'t croak');
84 $obj = new Hlagh(1, 2);
88 $obj = new Hlagh ( ) ;
90 $obj = new Hlagh ( 1 ) ;
92 $obj = new Hlagh ( 1 , 2 ) ;
117 $obj = new $x('foo');
119 $obj = new $x qq{foo}, 1;
121 $obj = new $x qr{foo\s+bar}, 1 .. 1;
123 $obj = new $x(qw/bar baz/);
131 $obj = new $_ qr/foo/ ;
133 $obj = new $_ qq(bar baz);
163 meh $sploosh::sploosh;
181 meh $sploosh::sploosh;
187 new Hlagh->wut, "Wut";
189 $obj = HlaghHlagh Hlagh;
191 $obj = HlaghHlagh Hlagh; # HlaghHlagh Hlagh
195 $obj = new newnew; # new newnew