1use strict; 2use warnings; 3 4use Test::More; 5use Test2::API qw/intercept/; 6 7my $events; 8{ 9 local $TODO = "main-outer-todo"; 10 11 package Foo; 12 13 our $TODO; 14 local $TODO = "foo-outer-todo"; 15 16 $events = main::intercept(sub { 17 main::ok(1, "assertion 1"); 18 19 { 20 local $main::TODO = "main-inner-todo"; 21 main::ok(1, "assertion 2"); 22 } 23 24 { 25 local $Foo::TODO = "foo-inner-todo"; 26 main::ok(1, "assertion 3"); 27 } 28 29 main::ok(1, "assertion 4"); 30 }); 31 32 # Cannot use intercept, so make a failing test, the overall test file 33 # should still pass because this is todo. If this is not todo we know we 34 # broke something by the test failing overall. 35 main::ok(0, "Verifying todo, this should be a failed todo test"); 36} 37 38@$events = grep { $_->facet_data->{assert} } @$events; 39 40ok(!$events->[0]->facet_data->{amnesty}, "No amnesty for the first event, \$TODO was cleaned"); 41 42is_deeply( 43 $events->[1]->facet_data->{amnesty}, 44 [{ 45 tag => 'TODO', 46 details => 'main-inner-todo', 47 }], 48 "The second event had the expected amnesty applied", 49); 50 51is_deeply( 52 $events->[2]->facet_data->{amnesty}, 53 [{ 54 tag => 'TODO', 55 details => 'foo-inner-todo', 56 }], 57 "The third event had the expected amnesty applied", 58); 59 60ok(!$events->[3]->facet_data->{amnesty}, "No amnesty for the fourth event, \$TODO was cleaned"); 61 62done_testing; 63