12 use Test::More tests => 33 * 4 + 2;
20 local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
23 eval "die qq{ok\\n}; $_";
25 is($@, "ok\n", "use indirect: $_");
28 eval "die qq{the code compiled but it shouldn't have\n}; $_";
30 like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"(?:new|meh|HlaghHlagh)"\s+on\s+object\s+"(?:Hlagh|newnew|\$x|\$_)"/, "no indirect: $_");
34 eval "die qq{ok\\n}; $_";
36 is($@, "ok\n", "use indirect, defined: $_");
39 eval "die qq{the code compiled but it shouldn't have\n}; $_";
41 like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"(?:new|meh|DongsDongs)"\s+on\s+object\s+"(?:Dongs|newnew|\$x|\$_)"/, "no indirect, defined: $_");
48 local $SIG{__WARN__} = sub { $warn = join ' ', @_ };
49 eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh1;";
50 like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh1"/, 'no indirect "hlagh" enables the pragma');
51 eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh2;";
52 like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh2"/, 'no indirect "hlagh" doesn\'t croak');
62 $obj = new Hlagh(1, 2);
66 $obj = new Hlagh ( ) ;
68 $obj = new Hlagh ( 1 ) ;
70 $obj = new Hlagh ( 1 , 2 ) ;
97 $obj = new $x qq{foo}, 1;
99 $obj = new $x qr{foo\s+bar}, 1 .. 1;
101 $obj = new $x(qw/bar baz/);
109 $obj = new $_ qr/foo/ ;
111 $obj = new $_ qq(bar baz);
121 new Hlagh->wut, "Wut";
123 $obj = HlaghHlagh Hlagh;
125 $obj = HlaghHlagh Hlagh; # HlaghHlagh Hlagh
129 $obj = new newnew; # new newnew