From: Vincent Pit Date: Fri, 5 Dec 2008 17:13:49 +0000 (+0100) Subject: Allow specifying a prefix and skipping individual tests X-Git-Tag: v0.09~8 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=256486fe8cf158890b5bd5048d7467d6809b4f2e;p=perl%2Fmodules%2Findirect.git Allow specifying a prefix and skipping individual tests --- diff --git a/t/10-good.t b/t/10-good.t index 7151361..da9b2d7 100644 --- a/t/10-good.t +++ b/t/10-good.t @@ -19,30 +19,41 @@ state $z; sub meh; { - local $/ = "####\n"; + local $/ = "####"; while () { chomp; s/\s*$//; + s/(.*?)$//m; + my ($skip, $prefix) = split /#+/, $1; + $skip = 0 unless defined $skip; + $prefix = '' unless defined $prefix; + s/\s*//; - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; +SKIP: + { + skip "$_: $skip" => 4 if eval $skip; + + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect: $_"); - eval "die qq{ok\n}; no indirect; $_"; - is($@, "ok\n", "no indirect: $_"); + eval "die qq{ok\n}; $prefix; no indirect; $_"; + is($@, "ok\n", "no indirect: $_"); - s/Hlagh/Dongs/g; + s/Hlagh/Dongs/g; - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect, defined: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect, defined: $_"); - eval "die qq{ok\\n}; no indirect; $_"; - is($@, "ok\n", "no indirect, defined: $_"); + eval "die qq{ok\\n}; $prefix; no indirect; $_"; + is($@, "ok\n", "no indirect, defined: $_"); + } } } __DATA__ + $obj = Hlagh->new; #### $obj = Hlagh->new(); diff --git a/t/20-bad.t b/t/20-bad.t index 35c8723..65511fd 100644 --- a/t/20-bad.t +++ b/t/20-bad.t @@ -23,35 +23,45 @@ sub expect { } { - local $/ = "####\n"; + local $/ = "####"; while () { chomp; s/\s*$//; + s/(.*?)$//m; + my ($skip, $prefix) = split /#+/, $1; + $skip = 0 unless defined $skip; + $prefix = '' unless defined $prefix; + s/\s*//; - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; +SKIP: + { + skip "$_: $skip" => 6 if eval $skip; - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect: $_"); + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; - like($@, expect('Hlagh'), "no indirect: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect: $_"); - s/Hlagh/Dongs/g; + eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_"; + like($@, expect('Hlagh'), "no indirect: $_"); - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect, defined: $_"); + s/Hlagh/Dongs/g; - eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; - like($@, expect('Dongs'), "no indirect, defined: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect, defined: $_"); - s/\$/\$ \n\t /g; - s/Dongs/Hlagh/g; + eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_"; + like($@, expect('Dongs'), "no indirect, defined: $_"); - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect, spaces: $_"); + s/\$/\$ \n\t /g; + s/Dongs/Hlagh/g; - eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; - like($@, expect('Hlagh'), "no indirect, spaces: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect, spaces: $_"); + + eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_"; + like($@, expect('Hlagh'), "no indirect, spaces: $_"); + } } } @@ -64,6 +74,7 @@ eval { } __DATA__ + $obj = new Hlagh; #### $obj = new Hlagh(); diff --git a/t/22-bad-mixed.t b/t/22-bad-mixed.t index 3a01f46..8cc0931 100644 --- a/t/22-bad-mixed.t +++ b/t/22-bad-mixed.t @@ -14,30 +14,41 @@ use Test::More tests => 3 * 4; sub meh; { - local $/ = "####\n"; + local $/ = "####"; while () { chomp; s/\s*$//; + s/(.*?)$//m; + my ($skip, $prefix) = split /#+/, $1; + $skip = 0 unless defined $skip; + $prefix = '' unless defined $prefix; + s/\s*//; - local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; +SKIP: + { + skip "$_: $skip" => 4 if eval $skip; - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect: $_"); + local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) }; - eval "die qq{ok\n}; no indirect; $_"; - is($@, "ok\n", "no indirect: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect: $_"); - s/Hlagh/Dongs/g; + eval "die qq{ok\n}; $prefix; no indirect; $_"; + is($@, "ok\n", "no indirect: $_"); - eval "die qq{ok\\n}; use indirect; $_"; - is($@, "ok\n", "use indirect, defined: $_"); + s/Hlagh/Dongs/g; - eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_"; - like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_"); + eval "die qq{ok\\n}; $prefix; use indirect; $_"; + is($@, "ok\n", "use indirect, defined: $_"); + + eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_"; + like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_"); + } } } __DATA__ + meh Hlagh->new; #### meh Hlagh->new();