| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Assert::Refute::Driver::More; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
319
|
use 5.006; |
|
|
16
|
|
|
|
|
65
|
|
|
4
|
16
|
|
|
16
|
|
106
|
use strict; |
|
|
16
|
|
|
|
|
37
|
|
|
|
16
|
|
|
|
|
330
|
|
|
5
|
16
|
|
|
16
|
|
77
|
use warnings; |
|
|
16
|
|
|
|
|
46
|
|
|
|
16
|
|
|
|
|
751
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
|
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
|
16
|
|
|
16
|
|
101
|
use Carp; |
|
|
16
|
|
|
|
|
40
|
|
|
|
16
|
|
|
|
|
1230
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
16
|
|
|
16
|
|
124
|
use parent qw(Assert::Refute::Report); |
|
|
16
|
|
|
|
|
31
|
|
|
|
16
|
|
|
|
|
140
|
|
|
49
|
16
|
|
|
16
|
|
1276
|
use Assert::Refute::Build qw(to_scalar); |
|
|
16
|
|
|
|
|
34
|
|
|
|
16
|
|
|
|
|
11358
|
|
|
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
|
17
|
|
|
17
|
1
|
57
|
my ($class, %opt) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
17
|
50
|
|
|
|
196
|
confess "Test::Builder not initialised, refusing toi proceed" |
|
62
|
|
|
|
|
|
|
unless Test::Builder->can("new"); |
|
63
|
|
|
|
|
|
|
|
|
64
|
17
|
|
|
|
|
151
|
my $self = $class->SUPER::new(%opt); |
|
65
|
17
|
|
|
|
|
89
|
$self->{builder} = Test::Builder->new; # singletone this far |
|
66
|
17
|
|
|
|
|
359
|
$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
|
33
|
|
|
33
|
1
|
107
|
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
|
33
|
|
|
|
|
76
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
33
|
|
|
|
|
159
|
$self->{count} = $self->{builder}->current_test; |
|
86
|
33
|
|
|
|
|
5451
|
$self->{builder}->ok(!$reason, $mess); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# see Assert::Refute::Report->get_result_detail |
|
89
|
33
|
50
|
66
|
|
|
16354
|
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
|
|
|
|
|
28
|
$self->{builder}->diag(to_scalar($reason)); |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Do we even need to track it here? |
|
96
|
33
|
|
|
|
|
1371
|
$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
|
|
1175
|
my $rep = (ref $self)->new( builder => $self->{builder} )->do_run( |
|
110
|
|
|
|
|
|
|
$todo, @args |
|
111
|
|
|
|
|
|
|
); |
|
112
|
|
|
|
|
|
|
# TODO also save $rep result in $self |
|
113
|
1
|
|
|
|
|
7
|
} ); |
|
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
|
|
|
|
|
820
|
$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
|
7
|
my ($self, $indent, $level, @mess) = @_; |
|
138
|
|
|
|
|
|
|
|
|
139
|
2
|
100
|
|
|
|
8
|
if ($level == -1) { |
|
|
|
50
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
5
|
$self->{builder}->diag($_) for @mess; |
|
141
|
|
|
|
|
|
|
} elsif ($level > 0) { |
|
142
|
1
|
|
|
|
|
7
|
$self->{builder}->note($_) for @mess; |
|
143
|
|
|
|
|
|
|
}; |
|
144
|
|
|
|
|
|
|
|
|
145
|
2
|
|
|
|
|
881
|
$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
|
|
|
|
|
3
|
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
|
5
|
my $self = shift; |
|
167
|
2
|
|
|
|
|
7
|
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
|
|
|
12
|
if exists $self->{fail}{$n}; |
|
183
|
|
|
|
|
|
|
|
|
184
|
1
|
|
|
|
|
3
|
my @t = $self->{builder}->summary; |
|
185
|
1
|
50
|
33
|
|
|
137
|
$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
|
|
|
|
|
6
|
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; |