xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Simple/t/regression/817-subtest-todo.t (revision f3efcd0145415b7d44d9da97e0ad5c21b186ac61)
1use Test2::API qw(run_subtest context intercept);
2use Test::More;
3use Test2::Tools::Tiny qw/todo/;
4
5sub aaa {
6    my $ctx = context();
7    run_subtest(
8        "bad pass",
9        sub {
10            local $TODO = "third test";
11            ok(1, "ok");
12        }
13    );
14    $ctx->release;
15}
16
17sub bbb {
18    my $ctx = context();
19    run_subtest(
20        "bad fail",
21        sub {
22            local $TODO = "fourth test";
23            ok(0, "ok");
24        }
25    );
26
27    $ctx->release;
28}
29
30my $events = intercept {
31    Test::Builder->new->_add_ts_hooks();
32    aaa();
33    bbb();
34};
35
36is_deeply(
37    $events->[1]->{subevents}->[0]->{amnesty}->[0],
38    { tag => 'TODO', details => "third test" },
39    "Amnesty was set properly for first subtest assertion",
40);
41
42is_deeply(
43    $events->[3]->{subevents}->[0]->{amnesty}->[0],
44    { tag => 'TODO', details => "fourth test" },
45    "Amnesty was set properly for second subtest assertion",
46);
47
48done_testing;
49