Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not 'inherit' amnesty set via $TODO
Removed the logic that would accidentally ALWAYS set amnesty from local $TODO to be inherited. This logic is unnecessary as Test::Builder manages the $TODO state/stack itself, it will never be inherited. Fixes #817
- Loading branch information
Showing
2 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use Test2::API qw(run_subtest context intercept); | ||
use Test::More; | ||
use Test2::Tools::Tiny qw/todo/; | ||
|
||
sub aaa { | ||
my $ctx = context(); | ||
run_subtest( | ||
"bad pass", | ||
sub { | ||
local $TODO = "third test"; | ||
ok(1, "ok"); | ||
} | ||
); | ||
$ctx->release; | ||
} | ||
|
||
sub bbb { | ||
my $ctx = context(); | ||
run_subtest( | ||
"bad fail", | ||
sub { | ||
local $TODO = "fourth test"; | ||
ok(0, "ok"); | ||
} | ||
); | ||
|
||
$ctx->release; | ||
} | ||
|
||
my $events = intercept { | ||
Test::Builder->new->_add_ts_hooks(); | ||
aaa(); | ||
bbb(); | ||
}; | ||
|
||
is_deeply( | ||
$events->[1]->{subevents}->[0]->{amnesty}->[0], | ||
{ tag => 'TODO', details => "third test" }, | ||
"Amnesty was set properly for first subtest assertion", | ||
); | ||
|
||
is_deeply( | ||
$events->[3]->{subevents}->[0]->{amnesty}->[0], | ||
{ tag => 'TODO', details => "fourth test" }, | ||
"Amnesty was set properly for second subtest assertion", | ||
); | ||
|
||
done_testing; |