File Coverage

blib/lib/Test/Run/Straps/EventWrapper.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Test::Run::Straps::EventWrapper;
2              
3 1     1   33708 use strict;
  1         3  
  1         47  
4 1     1   6 use warnings;
  1         2  
  1         29  
5              
6 1     1   1787 use Moose;
  0            
  0            
7              
8             use Test::Run::Base;
9              
10             extends('Test::Run::Base');
11              
12             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             {
60             my $self = shift;
61              
62             foreach my $predicate (qw(is_ok has_todo has_skip))
63             {
64             if ($self->$predicate())
65             {
66             return 1;
67             }
68             }
69              
70             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             {
82             my $self = shift;
83              
84             return ($self->is_test() ? ($self->number() +1 ) : undef);
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             1;