Run/Straps/EventWrapper.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 34 / 34 CC 4 SCAR 6.4
CC
4
Cov
100%
is_pass
3.0
get_next_test_number
2.0
BEGIN
1.0
CRAP 1.9
« Run/Obj/IntOrUnknown.pm ↑ Summary Run/Base/Plugger.pm »
1 package Test::Run::Straps::EventWrapper;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Test::Run::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 extends('Test::Run::Base');
11  
12 16 has '_tp_result' =>
13 (
14 is => "rw",
15 isa => "Maybe[TAP::Parser::Result]",
16 init_arg => "event",
17 handles => [qw(
18 comment
19 description
20 directive
21 explanation
22 has_skip
23 has_todo
24 is_actual_ok
25 is_bailout
26 is_comment
27 is_ok
28 is_plan
29 is_test
30 number
31 raw
32 tests_planned
33 )],
34 );
35  
36 =head1 NAME
37  
38 Test::Run::Straps::EventWrapper - a wrapper for a TAP::Parser::Result subclass
39 which delegates to its methods and has its own methods.
40  
41 =head1 DESCRIPTION
42  
43 L<TAP::Parser>'s C<next()> method returns a sub-class of
44 L<TAP::Parser::Result>. However, we need to define our own methods
45 on such objects. Since we cannot inherit from all the sub-classes, we
46 have created this class which holds an instance of the actual events,
47 delegates some methods to it, and defines some of its own methods.
48  
49 =cut
50  
51 =head2 $event->is_pass()
52  
53 Returns whether the event can be considered a passed event. Always returns a
54 scalar boolean.
55  
56 =cut
57  
58 sub is_pass
59 415 ▶{
Subroutine is_pass: called CC=3 SCAR=11.0
Pod documented
60 415 my $self = shift;
61  
62 415 foreach my $predicate (qw(is_ok has_todo has_skip))
63 {
64 525 ▶ if ($self->$predicate())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->$predicate) 360 165 525
65 {
66 360 return 1;
67 }
68 }
69  
70 55 return 0;
71 }
72  
73 =head2 $self->get_next_test_number()
74  
75 If this event is a test, then return the next expected test number. Else
76 return undef.
77  
78 =cut
79  
80 sub get_next_test_number
81 287 ▶{
Subroutine get_next_test_number: called CC=2 SCAR=6.9
Pod documented
82 287 my $self = shift;
83  
84 287 ▶ return ($self->is_test() ? ($self->number() +1 ) : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->is_test ? : 208 79 287
85 }
86  
87 =head1 SEE ALSO
88  
89 L<Test::Run::Straps>, L<Test::Run::Obj>, L<Test::Run::Core>
90  
91 =head1 LICENSE
92  
93 This file is licensed under the MIT X11 License:
94  
95 http://www.opensource.org/licenses/mit-license.php
96  
97 =head1 AUTHOR
98  
99 Shlomi Fish, L<http://www.shlomifish.org/>.
100  
101 =cut
102  
103 16 1;
« Run/Obj/IntOrUnknown.pm ↑ Summary Run/Base/Plugger.pm »