File Coverage

blib/lib/Test2/Event/Ok.pm
Criterion Covered Total %
statement 34 34 100.0
branch 12 12 100.0
condition 7 8 87.5
subroutine 10 10 100.0
pod 3 4 75.0
total 66 68 97.0


line stmt bran cond sub pod time code
1             package Test2::Event::Ok;
2 57     57   501 use strict;
  57         69  
  57         1249  
3 57     57   156 use warnings;
  57         48  
  57         2097  
4              
5             our $VERSION = '0.000043';
6             $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
7              
8 57     57   165 use base 'Test2::Event';
  57         59  
  57         18173  
9 57         151 use Test2::Util::HashBase qw{
10             pass effective_pass name todo
11 57     57   226 };
  57         60  
12              
13             sub init {
14 1048     1048 0 836 my $self = shift;
15              
16             # Do not store objects here, only true or false
17 1048 100       1995 $self->{+PASS} = $self->{+PASS} ? 1 : 0;
18 1048   66     2187 $self->{+EFFECTIVE_PASS} = $self->{+PASS} || (defined($self->{+TODO}) ? 1 : 0);
19              
20 1048 100       1721 my $name = $self->{+NAME} or return;
21 1029 100 100     5101 return unless index($name, '#') != -1 || index($name, "\n") != -1;
22 2         10 $self->trace->throw("'$name' is not a valid name, names must not contain '#' or newlines.")
23             }
24              
25             {
26 57     57   224 no warnings 'redefine';
  57         61  
  57         9416  
27             sub set_todo {
28 9     9   34 my $self = shift;
29 9         11 my ($todo) = @_;
30 9         13 $self->{+TODO} = $todo;
31 9 100       24 $self->{+EFFECTIVE_PASS} = defined($todo) ? 1 : $self->{+PASS};
32             }
33             }
34              
35 205     205 1 559 sub increments_count { 1 };
36              
37 42     42 1 87 sub causes_fail { !$_[0]->{+EFFECTIVE_PASS} }
38              
39             sub summary {
40 7     7 1 14 my $self = shift;
41              
42 7   100     17 my $name = $self->{+NAME} || "Nameless Assertion";
43              
44 7         6 my $todo = $self->{+TODO};
45 7 100       15 if ($todo) {
    100          
46 1         3 $name .= " (TODO: $todo)";
47             }
48             elsif (defined $todo) {
49 1         2 $name .= " (TODO)"
50             }
51              
52 7         23 return $name;
53             }
54              
55             1;
56              
57             __END__