From: Vincent Pit Date: Thu, 16 Oct 2008 13:21:55 +0000 (+0200) Subject: Factorize the regexp in t/20-bad.t X-Git-Tag: v0.07_03~4 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=commitdiff_plain;h=a26912556e065ea799bd946af5274c089c817838 Factorize the regexp in t/20-bad.t --- diff --git a/t/20-bad.t b/t/20-bad.t index 57df08f..8bd5602 100644 --- a/t/20-bad.t +++ b/t/20-bad.t @@ -14,6 +14,11 @@ use Test::More tests => 44 * 4 + 2; my ($obj, $x); our ($y, $bloop); +sub expect { + my ($pkg) = @_; + return qr/^warn:Indirect call of method "(?:new|meh|$pkg$pkg)" on object "(?:$pkg|newnew|\$(?:[xy_]|(?:sploosh::)?sploosh|(?:main::)?bloop))"/ +} + { local $/ = "####\n"; while () { @@ -28,7 +33,7 @@ our ($y, $bloop); no indirect; 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|\$[xy_]|\$(?:sploosh::)?sploosh|\$(?:main::)?bloop)"/, "no indirect: $_"); + like($@, expect('Hlagh'), "no indirect: $_"); s/Hlagh/Dongs/g; { use indirect; @@ -39,7 +44,7 @@ our ($y, $bloop); no indirect; 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|DongsDongs)"\s+on\s+object\s+"(?:Dongs|newnew|\$[xy_]|\$(?:sploosh::)?sploosh|\$(?:main::)?bloop)"/, "no indirect, defined: $_"); + like($@, expect('Dongs'), "no indirect, defined: $_"); } }