diff options
Diffstat (limited to 'cpan/Test-Simple/lib/Test2/Event/Subtest.pm')
-rw-r--r-- | cpan/Test-Simple/lib/Test2/Event/Subtest.pm | 105 |
1 files changed, 67 insertions, 38 deletions
diff --git a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm index 2b3c773bf6..56c4c0735f 100644 --- a/cpan/Test-Simple/lib/Test2/Event/Subtest.pm +++ b/cpan/Test-Simple/lib/Test2/Event/Subtest.pm @@ -2,50 +2,49 @@ package Test2::Event::Subtest; use strict; use warnings; -our $VERSION = '1.302073'; - +our $VERSION = '1.302096'; BEGIN { require Test2::Event::Ok; our @ISA = qw(Test2::Event::Ok) } use Test2::Util::HashBase qw{subevents buffered subtest_id}; sub init { - my $self = shift; - $self->SUPER::init(); - $self->{+SUBEVENTS} ||= []; - if ($self->{+EFFECTIVE_PASS}) { - $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; - } + my $self = shift; + $self->SUPER::init(); + $self->{+SUBEVENTS} ||= []; + if ($self->{+EFFECTIVE_PASS}) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; + } } { - no warnings 'redefine'; - - sub set_subevents { - my $self = shift; - my @subevents = @_; - - if ($self->{+EFFECTIVE_PASS}) { - $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @subevents; - } - - $self->{+SUBEVENTS} = \@subevents; - } - - sub set_effective_pass { - my $self = shift; - my ($pass) = @_; - - if ($pass) { - $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; - } - elsif ($self->{+EFFECTIVE_PASS} && !$pass) { - for my $s (grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}) { - $_->set_effective_pass(0) unless $s->can('todo') && defined $s->todo; - } - } - - $self->{+EFFECTIVE_PASS} = $pass; - } + no warnings 'redefine'; + + sub set_subevents { + my $self = shift; + my @subevents = @_; + + if ($self->{+EFFECTIVE_PASS}) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @subevents; + } + + $self->{+SUBEVENTS} = \@subevents; + } + + sub set_effective_pass { + my $self = shift; + my ($pass) = @_; + + if ($pass) { + $_->set_effective_pass(1) for grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}; + } + elsif ($self->{+EFFECTIVE_PASS} && !$pass) { + for my $s (grep { $_->can('effective_pass') } @{$self->{+SUBEVENTS}}) { + $_->set_effective_pass(0) unless $s->can('todo') && defined $s->todo; + } + } + + $self->{+EFFECTIVE_PASS} = $pass; + } } sub summary { @@ -58,12 +57,42 @@ sub summary { $name .= " (TODO: $todo)"; } elsif (defined $todo) { - $name .= " (TODO)" + $name .= " (TODO)"; } return $name; } +sub facet_data { + my $self = shift; + + my $out = $self->SUPER::facet_data(); + + $out->{parent} = { + hid => $self->subtest_id, + children => [map {$_->facet_data} @{$self->{+SUBEVENTS}}], + buffered => $self->{+BUFFERED}, + }; + + return $out; +} + +sub add_amnesty { + my $self = shift; + + for my $am (@_) { + $am = {%$am} if ref($am) ne 'ARRAY'; + $am = Test2::EventFacet::Amnesty->new($am); + + push @{$self->{+AMNESTY}} => $am; + + for my $e (@{$self->{+SUBEVENTS}}) { + $e->add_amnesty($am->clone(inherited => 1)); + } + } +} + + 1; __END__ @@ -121,7 +150,7 @@ F<http://github.com/Test-More/test-more/>. =head1 COPYRIGHT -Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>. +Copyright 2017 Chad Granum E<lt>exodist@cpan.orgE<gt>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |