X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=t%2F20-good.t;h=353949893fe4d9fdb2117ba5b4c393638fe5e9ec;hp=88d80603cbae021567a929cbc75fb85206526595;hb=e11d9a3efc1dcc5648202bd7651a982477bbc587;hpb=9856d89db33e335664cca6910de72b53e0e12763 diff --git a/t/20-good.t b/t/20-good.t index 88d8060..3539498 100644 --- a/t/20-good.t +++ b/t/20-good.t @@ -9,11 +9,26 @@ package main; use strict; use warnings; -use Test::More tests => 56 * 4; +use Test::More tests => 56 * 8; + +BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } my ($obj, $pkg, $cb, $x, @a); our $y; sub meh; +sub zap (&); + +my @warns; + +sub try { + my ($code) = @_; + + @warns = (); + { + local $SIG{__WARN__} = sub { push @warns, @_ }; + eval $code; + } +} { local $/ = "####"; @@ -28,23 +43,30 @@ sub meh; SKIP: { - skip "$_: $skip" => 4 if eval $skip; - - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; + skip "$_: $skip" => 8 if eval $skip; - eval "die qq{ok\\n}; $prefix; use indirect; $_"; - is($@, "ok\n", "use indirect: $_"); + { + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect: $_"; + is @warns, 0, 'no reports'; - eval "die qq{ok\n}; $prefix; no indirect; $_"; - is($@, "ok\n", "no indirect: $_"); + try "return; $prefix; no indirect; $_"; + is $@, '', "no indirect: $_"; + is @warns, 0, 'no reports'; + } - s/Hlagh/Dongs/g; + { + local $_ = $_; + s/Hlagh/Dongs/g; - eval "die qq{ok\\n}; $prefix; use indirect; $_"; - is($@, "ok\n", "use indirect, defined: $_"); + try "return; $prefix; use indirect; $_"; + is $@, '', "use indirect, defined: $_"; + is @warns, 0, 'no reports'; - eval "die qq{ok\\n}; $prefix; no indirect; $_"; - is($@, "ok\n", "no indirect, defined: $_"); + try "return; $prefix; no indirect; $_"; + is $@, '', "no indirect, defined: $_"; + is @warns, 0, 'no reports'; + } } } } @@ -129,21 +151,6 @@ $obj = $pkg->$cb( $obj ); #### $obj = $pkg->$cb(qw/foo bar baz/); #### -$obj = new { $x }; -#### -$obj = new - { - $x } - (); -#### -$obj = new { - $x } qq/foo/; -#### -$obj = new - { - $x - }(qw/bar baz/); -#### meh; #### meh $_; @@ -191,3 +198,11 @@ exec { $a[0] } @a; system $x $x, @a; #### system { $a[0] } @a; +#### +zap { }; +#### +zap { 1; }; +#### +zap { 1; 1; }; +#### +zap { zap { }; 1; };