line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Assert::Refute::Driver::More; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
430
|
use 5.006; |
|
22
|
|
|
|
|
83
|
|
4
|
22
|
|
|
22
|
|
119
|
use strict; |
|
22
|
|
|
|
|
47
|
|
|
22
|
|
|
|
|
520
|
|
5
|
22
|
|
|
22
|
|
108
|
use warnings; |
|
22
|
|
|
|
|
53
|
|
|
22
|
|
|
|
|
1077
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.1501'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Assert::Refute::Driver::More - Test::More compatibility layer for Asser::Refute suite |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
In your test script: |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Test::More; |
17
|
|
|
|
|
|
|
use Assert::Refute qw(:all); # in that order |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $def = contract { |
20
|
|
|
|
|
|
|
# don't use is/ok/etc here |
21
|
|
|
|
|
|
|
my ($c, @args) = @_; |
22
|
|
|
|
|
|
|
$c->is (...); |
23
|
|
|
|
|
|
|
$c->like (...); |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
is foo(), $bar, "Normal test"; |
27
|
|
|
|
|
|
|
subcontract "Repeated test block 1", $def, $value1; |
28
|
|
|
|
|
|
|
like $string, qr/.../, "Another normal test"; |
29
|
|
|
|
|
|
|
subcontract "Repeated test block 2", $def, $value2; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
done_testing; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This class is useless in and of itself. |
36
|
|
|
|
|
|
|
It is auto-loaded as a bridge between L and L, |
37
|
|
|
|
|
|
|
B Test::More has been loaded B Assert::Refute. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
We override some methods of L below so that |
42
|
|
|
|
|
|
|
test results are fed to the more backend. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
22
|
|
|
22
|
|
143
|
use Carp; |
|
22
|
|
|
|
|
45
|
|
|
22
|
|
|
|
|
1582
|
|
47
|
|
|
|
|
|
|
|
48
|
22
|
|
|
22
|
|
146
|
use parent qw(Assert::Refute::Report); |
|
22
|
|
|
|
|
64
|
|
|
22
|
|
|
|
|
159
|
|
49
|
22
|
|
|
22
|
|
1644
|
use Assert::Refute::Build qw(to_scalar); |
|
22
|
|
|
|
|
62
|
|
|
22
|
|
|
|
|
14887
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Will automatically load L instance, |
54
|
|
|
|
|
|
|
which is assumed to be a singleton as of this writing. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
59
|
23
|
|
|
23
|
1
|
75
|
my ($class, %opt) = @_; |
60
|
|
|
|
|
|
|
|
61
|
23
|
50
|
|
|
|
234
|
confess "Test::Builder not initialised, refusing toi proceed" |
62
|
|
|
|
|
|
|
unless Test::Builder->can("new"); |
63
|
|
|
|
|
|
|
|
64
|
23
|
|
|
|
|
230
|
my $self = $class->SUPER::new(%opt); |
65
|
23
|
|
|
|
|
108
|
$self->{builder} = Test::Builder->new; # singletone this far |
66
|
23
|
|
|
|
|
437
|
$self; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 refute( $condition, $message ) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The allmighty refute() boils down to |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
ok !$condition, $message |
74
|
|
|
|
|
|
|
or diag $condition; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub refute { |
79
|
57
|
|
|
57
|
1
|
149
|
my ($self, $reason, $mess) = @_; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# TODO bug - if refute() is called directly as $contract->refute, |
82
|
|
|
|
|
|
|
# it will report the wrong file & line |
83
|
57
|
|
|
|
|
132
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
84
|
|
|
|
|
|
|
|
85
|
57
|
|
|
|
|
228
|
$self->{count} = $self->{builder}->current_test; |
86
|
57
|
|
|
|
|
8693
|
$self->{builder}->ok(!$reason, $mess); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# see Assert::Refute::Report->get_result_detail |
89
|
57
|
50
|
66
|
|
|
26118
|
if (ref $reason eq 'ARRAY') { |
|
|
100
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
$self->{builder}->diag(to_scalar($_)) for @$reason; |
91
|
|
|
|
|
|
|
} elsif ($reason and $reason ne 1) { |
92
|
4
|
|
|
|
|
21
|
$self->{builder}->diag(to_scalar($reason)); |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Do we even need to track it here? |
96
|
57
|
|
|
|
|
1574
|
$self->SUPER::refute($reason, $mess); |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 subcontract |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Proxy to L's subtest. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub subcontract { |
106
|
1
|
|
|
1
|
1
|
3
|
my ($self, $mess, $todo, @args) = @_; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$self->{builder}->subtest( $mess => sub { |
109
|
1
|
|
|
1
|
|
1013
|
my $rep = (ref $self)->new( builder => $self->{builder} )->do_run( |
110
|
|
|
|
|
|
|
$todo, @args |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
# TODO also save $rep result in $self |
113
|
1
|
|
|
|
|
8
|
} ); |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 done_testing |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Proxy for C in L. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub done_testing { |
123
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
5
|
$self->{builder}->done_testing; |
126
|
1
|
|
|
|
|
721
|
$self->SUPER::done_testing; |
127
|
|
|
|
|
|
|
}; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 do_log( $indent, $level, $message ) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Just fall back to diag/note. |
132
|
|
|
|
|
|
|
Indentation is ignored. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub do_log { |
137
|
2
|
|
|
2
|
1
|
8
|
my ($self, $indent, $level, @mess) = @_; |
138
|
|
|
|
|
|
|
|
139
|
2
|
100
|
|
|
|
8
|
if ($level == -1) { |
|
|
50
|
|
|
|
|
|
140
|
1
|
|
|
|
|
4
|
$self->{builder}->diag($_) for @mess; |
141
|
|
|
|
|
|
|
} elsif ($level > 0) { |
142
|
1
|
|
|
|
|
7
|
$self->{builder}->note($_) for @mess; |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
2
|
|
|
|
|
801
|
$self->SUPER::do_log( $indent, $level, @mess ); |
146
|
|
|
|
|
|
|
}; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 get_count |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Current test number. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub get_count { |
155
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
156
|
1
|
|
|
|
|
4
|
return $self->{builder}->current_test; |
157
|
|
|
|
|
|
|
}; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 is_passing |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Tell if the whole set is passing. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub is_passing { |
166
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
167
|
2
|
|
|
|
|
8
|
return $self->{builder}->is_passing; |
168
|
|
|
|
|
|
|
}; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 get_result |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Fetch result of n-th test. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
0 is for passing tests, a true value is for failing ones. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub get_result { |
179
|
2
|
|
|
2
|
1
|
5
|
my ($self, $n) = @_; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
return $self->{fail}{$n} || 0 |
182
|
2
|
100
|
50
|
|
|
21
|
if exists $self->{fail}{$n}; |
183
|
|
|
|
|
|
|
|
184
|
1
|
|
|
|
|
6
|
my @t = $self->{builder}->summary; |
185
|
1
|
50
|
33
|
|
|
140
|
$self->_croak( "Test $n has never been performed" ) |
186
|
|
|
|
|
|
|
unless $n =~ /^[1-9]\d*$/ and $n <= @t; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# Alas, no reason here |
189
|
1
|
|
|
|
|
7
|
return !$t[$n]; |
190
|
|
|
|
|
|
|
}; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
This module is part of L suite. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Copyright 2017-2018 Konstantin S. Uvarin. C<< >> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
199
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
200
|
|
|
|
|
|
|
copy of the full license at: |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
L |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |