File Coverage

blib/lib/Test/Run/Straps/EventWrapper.pm
Criterion Covered Total %
statement 19 19 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Test::Run::Straps::EventWrapper;
2              
3 15     15   24521 use strict;
  15         72  
  15         416  
4 15     15   80 use warnings;
  15         34  
  15         419  
5              
6 15     15   911 use Moose;
  15         475024  
  15         146  
7              
8 15     15   103629 use Test::Run::Base;
  15         51  
  15         3020  
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 415     415 1 3813 my $self = shift;
61              
62 415         928 foreach my $predicate (qw(is_ok has_todo has_skip))
63             {
64 525 100       3799 if ($self->$predicate())
65             {
66 360         10536 return 1;
67             }
68             }
69              
70 55         993 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 287     287 1 522 my $self = shift;
83              
84 287 100       1045 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;