/usr/share/doc/perl-Test-Simple/t/Test2/behavior
NameSizeModeActions
disable_ipc_a.t2030644editdlrm
disable_ipc_b.t2190644editdlrm
disable_ipc_c.t2560644editdlrm
disable_ipc_d.t4580644editdlrm
err_var.t1770644editdlrm
Formatter.t16770644editdlrm
init_croak.t5890644editdlrm
intercept.t11170644editdlrm
ipc_wait_timeout.t23510644editdlrm
nested_context_exception.t21390644editdlrm
no_load_api.t15610644editdlrm
run_subtest_inherit.t22640644editdlrm
special_names.t13140644editdlrm
subtest_bailout.t11820644editdlrm
Subtest_buffer_formatter.t26800644editdlrm
Subtest_callback.t9060644editdlrm
Subtest_events.t4410644editdlrm
Subtest_plan.t3550644editdlrm
Subtest_todo.t9320644editdlrm
Taint.t3560644editdlrm
trace_signature.t15070644editdlrm
uuid.t34140644editdlrm
Edit: /usr/share/doc/perl-Test-Simple/t/Test2/behavior/run_subtest_inherit.t (2264B)
use strict; use warnings; use Test2::Tools::Tiny; use Test2::API qw/run_subtest intercept context/; # Test a subtest that should inherit the trace from the tool that calls it my ($file, $line) = (__FILE__, __LINE__ + 1); my $events = intercept { my_tool_inherit() }; is(@$events, 1, "got 1 event"); my $e = shift @$events; ok($e->isa('Test2::Event::Subtest'), "got a subtest event"); is($e->trace->file, $file, "subtest is at correct file"); is($e->trace->line, $line, "subtest is at correct line"); my $plan = pop @{$e->subevents}; ok($plan->isa('Test2::Event::Plan'), "Removed plan"); for my $se (@{$e->subevents}) { is($se->trace->file, $file, "subtest event is at correct file"); is($se->trace->line, $line, "subtest event is at correct line"); ok($se->facets->{assert}->pass, "subtest event passed"); } # Test a subtest that should NOT inherit the trace from the tool that calls it ($file, $line) = (__FILE__, __LINE__ + 1); $events = intercept { my_tool_no_inherit() }; is(@$events, 1, "got 1 event"); $e = shift @$events; ok($e->isa('Test2::Event::Subtest'), "got a subtest event"); is($e->trace->file, $file, "subtest is at correct file"); is($e->trace->line, $line, "subtest is at correct line"); $plan = pop @{$e->subevents}; ok($plan->isa('Test2::Event::Plan'), "Removed plan"); for my $se (@{$e->subevents}) { ok($se->trace->file ne $file, "subtest event is not in our file"); ok($se->trace->line ne $line, "subtest event is not on our line"); ok($se->facets->{assert}->{pass}, "subtest event passed"); } done_testing; # Make these tools appear to be in a different file/line #line 100 'fake.pm' sub my_tool_inherit { my $ctx = context(); run_subtest( 'foo', sub { ok(1, 'a'); ok(2, 'b'); is_deeply(\@_, [qw/arg1 arg2/], "got args"); }, {buffered => 1, inherit_trace => 1}, 'arg1', 'arg2' ); $ctx->release; } sub my_tool_no_inherit { my $ctx = context(); run_subtest( 'foo', sub { ok(1, 'a'); ok(2, 'b'); is_deeply(\@_, [qw/arg1 arg2/], "got args"); }, {buffered => 1, inherit_trace => 0}, 'arg1', 'arg2' ); $ctx->release; }