X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F20-bad.t;h=35c8723ff752ebb26573ee24ca5e2ab323a2ddb4;hb=16e155017652cb3e07702075aae4bbdc512e1480;hp=136b381934060d8ee22e550b8ac5f9af4a645aaa;hpb=faed8ab9b402954feb3efbffbb1ce53aafd53fc1;p=perl%2Fmodules%2Findirect.git diff --git a/t/20-bad.t b/t/20-bad.t index 136b381..35c8723 100644 --- a/t/20-bad.t +++ b/t/20-bad.t @@ -27,51 +27,40 @@ sub expect { while () { chomp; s/\s*$//; + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - { - use indirect; - eval "die qq{ok\\n}; $_"; - } + + eval "die qq{ok\\n}; use indirect; $_"; is($@, "ok\n", "use indirect: $_"); - { - no indirect; - eval "die qq{the code compiled but it shouldn't have\n}; $_"; - } + + eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; like($@, expect('Hlagh'), "no indirect: $_"); + s/Hlagh/Dongs/g; - { - use indirect; - eval "die qq{ok\\n}; $_"; - } + + eval "die qq{ok\\n}; use indirect; $_"; is($@, "ok\n", "use indirect, defined: $_"); - { - no indirect; - eval "die qq{the code compiled but it shouldn't have\n}; $_"; - } + + eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; like($@, expect('Dongs'), "no indirect, defined: $_"); + s/\$/\$ \n\t /g; s/Dongs/Hlagh/g; - { - use indirect; - eval "die qq{ok\\n}; $_"; - } + + eval "die qq{ok\\n}; use indirect; $_"; is($@, "ok\n", "use indirect, spaces: $_"); - { - no indirect; - eval "die qq{the code compiled but it shouldn't have\n}; $_"; - } + + eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; like($@, expect('Hlagh'), "no indirect, spaces: $_"); } } eval { - no indirect 'hlagh'; my $warn; local $SIG{__WARN__} = sub { $warn = join ' ', @_ }; - eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh1;"; + eval "die qq{ok\n}; no indirect 'hlagh'; \$obj = new Hlagh1;"; + is($@, "ok\n", 'no indirect "hlagh" didn\'t croak'); like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh1"/, 'no indirect "hlagh" enables the pragma'); - eval "die qq{the code compiled but it shouldn't have\n}; \$obj = new Hlagh2;"; - like($warn, qr/^Indirect\s+call\s+of\s+method\s+"new"\s+on\s+object\s+"Hlagh2"/, 'no indirect "hlagh" doesn\'t croak'); } __DATA__