X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=t%2F20-bad.t;fp=t%2F20-bad.t;h=05efb509b5698f88cd434b0a6b28e5437b8f6d0d;hp=0000000000000000000000000000000000000000;hb=7ded1e91a0a0ddc3e709cda9573fe0e53a32e092;hpb=7f756d0f409eb87eb7900dafdb81428e4367021b diff --git a/t/20-bad.t b/t/20-bad.t new file mode 100644 index 0000000..05efb50 --- /dev/null +++ b/t/20-bad.t @@ -0,0 +1,97 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 28 * 2; + +my ($obj, $pkg, $cb, $x); + +{ + local $/ = "####\n"; + while () { + chomp; + { + use indirect; + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; + eval "die qq{ok\\n}; $_"; + } + is($@, "ok\n", $_); + { + no indirect; + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; + eval "die qq{the code compiled but it shouldn't have\n}; $_"; + } + like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"(?:new|meh|HlaghHlagh)"\s+on\s+object\s+"(?:Hlagh|newnew|\$x|\$_)"/, $_); + } +} + +__DATA__ +$obj = new Hlagh; +#### +$obj = new Hlagh(); +#### +$obj = new Hlagh(1); +#### +$obj = new Hlagh(1, 2); +#### +$obj = new Hlagh ; +#### +$obj = new Hlagh ( ) ; +#### +$obj = new Hlagh ( 1 ) ; +#### +$obj = new Hlagh ( 1 , 2 ) ; +#### +$obj = new + Hlagh + ; +#### +$obj = new + Hlagh ( + ) ; +#### +$obj = + new + Hlagh ( 1 + ) ; +#### +$obj = +new +Hlagh + ( 1 , + 2 ) ; +#### +$obj = new $x; +#### +$obj = new $x(); +#### +$obj = new $x('foo'); +#### +$obj = new $x qq{foo}, 1; +#### +$obj = new $x qr{foo\s+bar}, 1 .. 1; +#### +$obj = new $x(qw/bar baz/); +#### +$obj = new + $_; +#### +$obj = new + $_ ( ); +#### +$obj = new $_ qr/foo/ ; +#### +$obj = new $_ qq(bar baz); +#### +meh $x; +#### +meh $x, 1, 2; +#### +$obj = HlaghHlagh Hlagh; +#### +$obj = HlaghHlagh Hlagh; # HlaghHlagh Hlagh +#### +$obj = new newnew; +#### +$obj = new newnew; # new newnew