blib/lib/Test/Unit/Result.pm

filter: Statementstmt 17.5% 17 / 97 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 19.3% 6 / 31 Podpod 0.0% 0 / 21 totaltotal 14.5% 23 / 158 CC 5 SCAR 10.1
CC
5
Cov
16%
tell_listeners
6.0
__ANON__
6.0
__ANON__
6.0
CRAP 2.7
« blib/lib/Test/Unit/Assertion/Regexp.pm ↑ Summary blib/lib/Test/TestLister.pl »
1 package Test::Unit::Result;
2 BEGIN {
3 6 ▶ $Test::Unit::Result::VERSION = '0.25_1325'; # added by dist-tools/SetVersion.pl
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Test::Unit::Debug qw(debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Test::Unit::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Test::Unit::Failure;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use Error qw/:try/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub new {
14 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
15 0 bless {
16 _Failures => [],
17 _Errors => [],
18 _Listeners => [],
19 _Run_tests => 0,
20 _Stop => 0,
21 }, $class;
22 }
23  
24 sub tell_listeners {
25 0 ▶ my $self = shift;
Subroutine tell_listeners: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my $method = shift;
27 0 foreach (@{$self->listeners}) {
28 0 $_->$method(@_);
29 }
30 }
31  
32 sub add_error {
33 0 ▶ my $self = shift;
Subroutine add_error: not called CC=1 SCAR=6.9
Pod undocumented
34 0 debug($self . "::add_error() called\n");
35 0 my ($test, $exception) = @_;
36 0 $exception->{-object} = $test;
37 0 push @{$self->errors()}, $exception;
38 0 $self->tell_listeners(add_error => @_);
39 }
40  
41 sub add_failure {
42 0 ▶ my $self = shift;
Subroutine add_failure: not called CC=1 SCAR=6.9
Pod undocumented
43 0 debug($self . "::add_failure() called\n");
44 0 my ($test, $exception) = @_;
45 0 $exception->{-object} = $test;
46 0 push @{$self->failures()}, $exception;
47 0 $self->tell_listeners(add_failure => @_);
48 }
49  
50 sub add_pass {
51 0 ▶ my $self = shift;
Subroutine add_pass: not called CC=1 SCAR=6.9
Pod undocumented
52 0 debug($self . "::add_pass() called\n");
53 0 my ($test) = @_;
54 0 $self->tell_listeners(add_pass => @_);
55 }
56  
57 sub add_listener {
58 0 ▶ my $self = shift;
Subroutine add_listener: not called CC=1 SCAR=6.9
Pod undocumented
59 0 debug($self . "::add_listener() called\n");
60 0 my ($listener) = @_;
61 0 push @{$self->listeners()}, $listener;
62 }
63  
64 sub listeners {
65 0 ▶ my $self = shift;
Subroutine listeners: not called CC=1 SCAR=6.9
Pod undocumented
66 0 return $self->{_Listeners};
67 }
68  
69 sub end_test {
70 0 ▶ my $self = shift;
Subroutine end_test: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($test) = @_;
72 0 $self->tell_listeners(end_test => $test);
73 }
74  
75 sub error_count {
76 0 ▶ my $self = shift;
Subroutine error_count: not called CC=1 SCAR=6.9
Pod undocumented
77 0 return scalar @{$self->{_Errors}};
78 }
79  
80 sub errors {
81 0 ▶ my $self = shift;
Subroutine errors: not called CC=1 SCAR=6.9
Pod undocumented
82 0 return $self->{_Errors};
83 }
84
85 sub failure_count {
86 0 ▶ my $self = shift;
Subroutine failure_count: not called CC=1 SCAR=6.9
Pod undocumented
87 0 return scalar @{$self->{_Failures}};
88 }
89  
90 sub failures {
91 0 ▶ my $self = shift;
Subroutine failures: not called CC=1 SCAR=6.9
Pod undocumented
92 0 return $self->{_Failures};
93 }
94  
95 sub run {
96 0 ▶ my $self = shift;
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
97 0 my ($test) = @_;
98 0 debug(sprintf "%s::run(%s) called\n", $self, $test->name());
99 0 $self->start_test($test);
100  
101 # This closure may look convoluted, but it allows Test::Unit::Setup
102 # to work cleanly.
103 $self->run_protected(
104 $test,
105 sub {
106 0 ▶ $test->run_bare() ?
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$test->run_bare ? : 0 0 0
107 $self->add_pass($test)
108 : $self->add_failure($test);
109 }
110 0 );
111  
112 0 $self->end_test($test);
113 }
114  
115 sub run_protected {
116 0 ▶ my $self = shift;
Subroutine run_protected: not called CC=1 SCAR=6.9
Pod undocumented
117 0 my $test = shift;
118 0 my $protectable = shift;
119 0 debug("$self\::run_protected($test, $protectable) called\n");
120  
121 try {
122 0 ▶ &$protectable();
Subroutine __ANON__: not called CC=1 SCAR=6.9
123 }
124 catch Test::Unit::Failure with {
125 0 ▶ $self->add_failure($test, shift);
Subroutine __ANON__: not called CC=1 SCAR=6.9
126 }
127 catch Error with {
128 # *Any* exception which isn't a failure or
129 # Test::Unit::Exception should get rebuilt and added to the
130 # result as a Test::Unit::Error, so that the stringify()
131 # method can be called on it for nice reporting.
132 0 ▶ my $error = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
133 0 ▶ $error = Test::Unit::Error->make_new_from_error($error)
Branch: 1 branch
BranchTrueFalseTotal
unless $error->isa("Test::Unit::Exception") 0 0 0
134 unless $error->isa('Test::Unit::Exception');
135 0 $self->add_error($test, $error);
136 0 };
137 }
138  
139 sub run_count {
140 0 ▶ my $self = shift;
Subroutine run_count: not called CC=1 SCAR=6.9
Pod undocumented
141 0 return $self->{_Run_tests};
142 }
143  
144 sub run_count_inc {
145 0 ▶ my $self = shift;
Subroutine run_count_inc: not called CC=1 SCAR=6.9
Pod undocumented
146 0 ++$self->{_Run_tests};
147 0 return $self->{_Run_tests};
148 }
149
150 sub should_stop {
151 0 ▶ my $self = shift;
Subroutine should_stop: not called CC=1 SCAR=6.9
Pod undocumented
152 0 return $self->{_Stop};
153 }
154
155 sub start_test {
156 0 ▶ my $self = shift;
Subroutine start_test: not called CC=1 SCAR=6.9
Pod undocumented
157 0 my ($test) = @_;
158 0 $self->run_count_inc();
159 0 $self->tell_listeners(start_test => $test);
160 }
161  
162 sub stop {
163 0 ▶ my $self = shift;
Subroutine stop: not called CC=1 SCAR=6.9
Pod undocumented
164 0 $self->{_Stop} = 1;
165 }
166  
167 sub was_successful {
168 0 ▶ my $self = shift;
Subroutine was_successful: not called CC=2 SCAR=17.9
Pod undocumented
169 0 ▶ return ($self->failure_count() == 0) && ($self->error_count() == 0);
Condition0%0/3
$self->failure_count == 0 && $self->error_count == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->failure_count == 0 && $self->error_count == 0
$self->failure_count == 0 $self->error_count == 0
Truth table0%0/3
A && B
A= $self->failure_count == 0B= $self->error_count == 0
ABresult
0X0
100
111
170 }
171  
172 sub to_string {
173 0 ▶ my $self = shift;
Subroutine to_string: not called CC=1 SCAR=6.9
Pod undocumented
174 0 my $class = ref($self);
175 0 debug($class . "::to_string() called\n");
176 }
177  
178 6 1;
179 __END__
« blib/lib/Test/Unit/Assertion/Regexp.pm ↑ Summary blib/lib/Test/TestLister.pl »