line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Extreme; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
697
|
use 5.012004; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1368
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT = qw( |
13
|
|
|
|
|
|
|
assert |
14
|
|
|
|
|
|
|
assert_true |
15
|
|
|
|
|
|
|
assert_false |
16
|
|
|
|
|
|
|
assert_passed |
17
|
|
|
|
|
|
|
assert_failed |
18
|
|
|
|
|
|
|
assert_some |
19
|
|
|
|
|
|
|
assert_none |
20
|
|
|
|
|
|
|
assert_is_array |
21
|
|
|
|
|
|
|
assert_equals |
22
|
|
|
|
|
|
|
assert_contains |
23
|
|
|
|
|
|
|
assert_subset |
24
|
|
|
|
|
|
|
assert_is_array |
25
|
|
|
|
|
|
|
assert_is_hash |
26
|
|
|
|
|
|
|
assert_size |
27
|
|
|
|
|
|
|
assert_keys |
28
|
|
|
|
|
|
|
assert_is_string |
29
|
|
|
|
|
|
|
run_tests |
30
|
|
|
|
|
|
|
run_tests_as_script |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub assert($) { |
37
|
247
|
100
|
|
247
|
0
|
466
|
if ($_[0]) { return; } |
|
215
|
|
|
|
|
385
|
|
38
|
32
|
50
|
|
|
|
86
|
if (defined($@)) { confess "Assertion failed.\n$@"; undef $@; } |
|
32
|
|
|
|
|
10306
|
|
|
0
|
|
|
|
|
0
|
|
39
|
0
|
|
|
|
|
0
|
else { confess "Assertion failed.\n"; } |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
218
|
|
|
218
|
0
|
370
|
sub assert_true($) { assert $_[0] } |
43
|
28
|
|
|
28
|
0
|
51
|
sub assert_false($) { assert ! $_[0] } |
44
|
23
|
|
|
23
|
0
|
41
|
sub assert_passed() { assert_false $@ } |
45
|
33
|
|
|
33
|
0
|
79
|
sub assert_failed() { assert_true $@ } |
46
|
2
|
|
|
2
|
0
|
7
|
sub assert_some($) { assert_true $_[0] } |
47
|
3
|
|
|
3
|
0
|
8
|
sub assert_none($) { assert_false $_[0] } |
48
|
|
|
|
|
|
|
|
49
|
157
|
|
|
157
|
0
|
310
|
sub assert_equals_string($$) { assert_true($_[0] eq $_[1]) } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub assert_is_array($); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub assert_equals_array($$) { |
54
|
17
|
|
|
17
|
0
|
25
|
my ($list0, $list1) = @_; |
55
|
17
|
|
|
|
|
34
|
assert_is_array $list0; |
56
|
16
|
|
|
|
|
33
|
assert_is_array $list1; |
57
|
15
|
|
|
|
|
39
|
assert_equals_string scalar @$list0, scalar @$list1; |
58
|
11
|
|
|
|
|
36
|
for (my $i = 0 ; $i < @$list0 ; ++$i) { |
59
|
23
|
|
|
|
|
55
|
assert_equals( $list0->[$i], $list1->[$i] ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub assert_equals_hash($$) { |
64
|
7
|
|
|
7
|
0
|
15
|
my ($hash0, $hash1) = @_; |
65
|
7
|
|
|
|
|
36
|
assert_equals_string scalar keys %$hash0, scalar keys %$hash1; |
66
|
4
|
|
|
|
|
7
|
for my $key (keys %{$hash0}) { |
|
4
|
|
|
|
|
11
|
|
67
|
8
|
|
|
|
|
15
|
assert_true exists $hash1->{$key}; |
68
|
8
|
|
|
|
|
18
|
assert_equals($hash0->{$key}, $hash1->{$key}); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub assert_equals($$) { |
73
|
150
|
100
|
|
150
|
0
|
440
|
assert_equals_string $_[0], $_[1] if ref $_[0] eq ''; |
74
|
132
|
100
|
|
|
|
307
|
assert_equals_array $_[0], $_[1] if ref $_[0] eq 'ARRAY'; |
75
|
129
|
100
|
|
|
|
320
|
assert_equals_hash $_[0], $_[1] if ref $_[0] eq 'HASH'; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub assert_contains($$) { |
79
|
14
|
|
|
14
|
0
|
21
|
my ($element, $list) = @_; |
80
|
14
|
|
|
|
|
25
|
assert_equals "", ref $element; |
81
|
14
|
|
|
|
|
32
|
assert_equals "ARRAY", ref $list; |
82
|
14
|
|
|
|
|
24
|
eval { assert_true grep { $_ eq $element } @$list } ; |
|
14
|
|
|
|
|
22
|
|
|
142
|
|
|
|
|
235
|
|
83
|
14
|
100
|
|
|
|
1192
|
if ($@) { |
84
|
4
|
|
|
|
|
35
|
my $list_text = "[" . join(" " => @$list) . "]"; |
85
|
4
|
|
|
|
|
654
|
confess "Did not find $element in $list_text.\n$@" ; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub assert_subset($$) { |
90
|
6
|
|
|
6
|
0
|
13
|
my ($list1, $list2) = @_; |
91
|
6
|
|
|
|
|
19
|
assert_equals "ARRAY", ref $list1; |
92
|
6
|
|
|
|
|
17
|
assert_equals "ARRAY", ref $list2; |
93
|
6
|
|
|
|
|
11
|
for my $element (@$list1) |
94
|
10
|
|
|
|
|
21
|
{ assert_contains $element, $list2 } |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
46
|
|
|
46
|
0
|
110
|
sub assert_is_array($) { assert_equals 'ARRAY', ref $_[0] } |
98
|
|
|
|
|
|
|
|
99
|
11
|
|
|
11
|
0
|
57
|
sub assert_is_hash($) { assert_equals 'HASH', ref $_[0] } |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub assert_size($$) { |
102
|
5
|
|
|
5
|
0
|
9
|
my ($size, $array) = @_; |
103
|
5
|
|
|
|
|
9
|
assert_is_array $array; |
104
|
3
|
|
|
|
|
7
|
assert_equals $size, scalar @$array |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub assert_keys($$) { |
108
|
8
|
|
|
8
|
0
|
15
|
my ($keys, $hash) = @_; |
109
|
8
|
|
|
|
|
14
|
assert_is_hash $hash; |
110
|
5
|
|
|
|
|
13
|
assert_is_array $keys; |
111
|
5
|
|
|
|
|
11
|
my @actual_keys = sort keys %{$hash}; |
|
5
|
|
|
|
|
24
|
|
112
|
5
|
|
|
|
|
15
|
my @expected_keys = sort @$keys; |
113
|
5
|
|
|
|
|
11
|
assert_equals \@expected_keys, \@actual_keys |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub assert_is_string($) { |
117
|
3
|
|
|
3
|
0
|
6
|
my ($string) = @_; |
118
|
3
|
|
|
|
|
8
|
assert_equals '', ref $string; |
119
|
1
|
|
|
|
|
4
|
assert ($string =~ /\S/) |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _list_symbols { |
123
|
1
|
|
|
1
|
|
7
|
use vars qw /$symbol $sym @sym %sym/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
110
|
|
124
|
|
|
|
|
|
|
|
125
|
7
|
|
|
7
|
|
13
|
my $pkg = shift; |
126
|
7
|
|
|
|
|
11
|
my $prefix = shift; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
129
|
7
|
|
|
|
|
11
|
my %pkg_keys = %{$pkg}; |
|
7
|
|
|
|
|
800
|
|
130
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2270
|
|
131
|
|
|
|
|
|
|
|
132
|
7
|
|
|
|
|
43
|
my $symbols = []; |
133
|
7
|
|
|
|
|
70
|
foreach $symbol (keys %pkg_keys) { |
134
|
499
|
100
|
|
|
|
1721
|
next if $symbol !~ /^[\:\w]+$/s; # Skip if not-word |
135
|
257
|
|
|
|
|
458
|
my $symbol_path = $prefix . $pkg . $symbol ; |
136
|
|
|
|
|
|
|
# Need this because Perl 5.12 deprecates defined on hash |
137
|
257
|
100
|
|
|
|
437
|
if ($prefix eq '%') { |
138
|
94
|
100
|
|
|
|
4344
|
push @$symbols, $symbol if eval qq[!!($symbol_path)]; |
139
|
|
|
|
|
|
|
} else { |
140
|
163
|
100
|
|
|
|
7552
|
push @$symbols, $symbol if eval qq[ defined($symbol_path) ]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
7
|
|
|
|
|
157
|
@$symbols = sort @$symbols; |
144
|
7
|
|
|
|
|
218
|
return $symbols; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
6
|
|
|
6
|
|
18
|
sub _list_subs($) { return _list_symbols shift, '&' } |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub _list_packages($) { |
150
|
1
|
|
|
1
|
|
4
|
my $list = _list_symbols shift, '%' ; |
151
|
1
|
|
|
|
|
4
|
@$list = grep { /::$/ } @$list ; |
|
60
|
|
|
|
|
205
|
|
152
|
1
|
|
|
|
|
7
|
return $list; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub _list_tests($) { |
156
|
3
|
|
|
3
|
|
10
|
my ($pkg) = @_; |
157
|
3
|
|
|
|
|
7
|
my $list = _list_subs $pkg; |
158
|
3
|
|
|
|
|
10
|
@$list = map { $pkg . $_ } grep { /^_*[tT]est/ } @$list ; |
|
22
|
|
|
|
|
52
|
|
|
70
|
|
|
|
|
152
|
|
159
|
3
|
|
|
|
|
18
|
return $list; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _execute_tests($$$) { |
163
|
2
|
|
|
2
|
|
5
|
my ($all_tests, $failure_messages, $output) = @_; |
164
|
2
|
|
|
|
|
5
|
for my $test (@$all_tests) { |
165
|
1
|
|
|
1
|
|
10
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
166
|
21
|
|
|
|
|
28
|
eval { &{$test} }; |
|
21
|
|
|
|
|
23
|
|
|
21
|
|
|
|
|
85
|
|
167
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3595
|
|
168
|
21
|
100
|
|
|
|
285
|
if ($@) { |
169
|
1
|
50
|
|
|
|
5
|
print "F" if $output; |
170
|
1
|
|
|
|
|
5
|
$failure_messages->{$test} = $@; |
171
|
|
|
|
|
|
|
} |
172
|
20
|
50
|
|
|
|
52
|
else { print "." if $output } |
173
|
|
|
|
|
|
|
} |
174
|
2
|
50
|
|
|
|
7
|
print "\n" if $output; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub _print_failure_messages($$) { |
178
|
0
|
|
|
0
|
|
0
|
my ($all_tests, $failure_messages) = @_; |
179
|
0
|
|
|
|
|
0
|
for my $test (sort keys %{$failure_messages}) { |
|
0
|
|
|
|
|
0
|
|
180
|
0
|
|
|
|
|
0
|
print "$test: $failure_messages->{$test}" |
181
|
|
|
|
|
|
|
} |
182
|
0
|
|
|
|
|
0
|
print "\n"; |
183
|
0
|
|
|
|
|
0
|
my $test_count = scalar @$all_tests; |
184
|
0
|
|
|
|
|
0
|
my $fail_count = scalar keys %{$failure_messages}; |
|
0
|
|
|
|
|
0
|
|
185
|
0
|
|
|
|
|
0
|
my $pass_count = $test_count - $fail_count; |
186
|
0
|
0
|
|
|
|
0
|
my $test_or_tests = $test_count == 1 ? "test" : "tests"; |
187
|
0
|
0
|
|
|
|
0
|
if ($fail_count == 0) { |
188
|
0
|
|
|
|
|
0
|
print "OK ($test_count $test_or_tests)\n" |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else { |
191
|
0
|
|
|
|
|
0
|
print "Failures!!!\n\n"; |
192
|
0
|
|
|
|
|
0
|
print "Runs: $test_count, Passes: $pass_count, Fails: $fail_count\n"; |
193
|
|
|
|
|
|
|
} |
194
|
0
|
|
|
|
|
0
|
print "\n"; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub run_tests { |
198
|
0
|
|
|
0
|
0
|
0
|
my @pkgs = map { $_ . "::" } ( 'main' , @_); |
|
0
|
|
|
|
|
0
|
|
199
|
0
|
|
|
|
|
0
|
my $all_tests = []; |
200
|
0
|
|
|
|
|
0
|
for my $pkg (@pkgs) { push @$all_tests, @{ _list_tests $pkg }; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
0
|
my $failure_messages = {}; |
203
|
0
|
|
|
|
|
0
|
_execute_tests $all_tests, $failure_messages, 1; |
204
|
0
|
|
|
|
|
0
|
_print_failure_messages $all_tests, $failure_messages; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub run_tests_as_script { |
208
|
1
|
|
|
1
|
0
|
11
|
my @pkgs = map { $_ . "::" } ( 'main' , @_); |
|
2
|
|
|
|
|
8
|
|
209
|
1
|
|
|
|
|
3
|
my $all_tests = []; |
210
|
1
|
|
|
|
|
4
|
for my $pkg (@pkgs) { push @$all_tests, @{ _list_tests $pkg }; } |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
211
|
|
|
|
|
|
|
|
212
|
1
|
|
|
|
|
3
|
my $failure_messages = {}; |
213
|
1
|
|
|
|
|
6
|
_execute_tests $all_tests, $failure_messages, 0; |
214
|
|
|
|
|
|
|
|
215
|
1
|
|
|
|
|
11
|
print "1..", scalar @$all_tests, "\n"; |
216
|
1
|
|
|
|
|
6
|
for (my $i = 0 ; $i < @$all_tests ; ++$i) { |
217
|
19
|
|
|
|
|
31
|
my $test = $all_tests->[$i]; |
218
|
19
|
50
|
|
|
|
32
|
print "not " |
219
|
|
|
|
|
|
|
if exists $failure_messages->{$test}; |
220
|
19
|
|
|
|
|
41
|
print "ok ", 1 + $i; |
221
|
0
|
|
|
|
|
0
|
print "\n", join "\n" => |
222
|
19
|
50
|
|
|
|
37
|
map { "# " . $_ ; } |
223
|
|
|
|
|
|
|
split /\n/, $test . ": " . $failure_messages->{$test} |
224
|
|
|
|
|
|
|
if exists $failure_messages->{$test}; |
225
|
19
|
|
|
|
|
42
|
print "\n"; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
231
|
|
|
|
|
|
|
# TESTS BEGIN |
232
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
sub test_assert_true() { |
235
|
1
|
|
|
1
|
0
|
3
|
eval { assert_true 1 } ; assert_passed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
236
|
1
|
|
|
|
|
1
|
eval { assert_true 0 } ; assert_failed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
112
|
|
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub test_assert_false() { |
240
|
1
|
|
|
1
|
0
|
2
|
eval { assert_false 1 } ; assert_failed ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
107
|
|
241
|
1
|
|
|
|
|
2
|
eval { assert_false 0 } ; assert_passed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub test_assert_some() { |
245
|
1
|
|
|
1
|
0
|
2
|
eval { assert_some 1 } ; assert_passed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
246
|
1
|
|
|
|
|
2
|
eval { assert_some 0 } ; assert_failed ; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
122
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub test_assert_none() { |
250
|
1
|
|
|
1
|
0
|
2
|
eval { assert_none 1 } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
117
|
|
251
|
1
|
|
|
|
|
1
|
eval { assert_none 0 } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub test_assert_equals() { |
255
|
1
|
|
|
1
|
0
|
2
|
eval { assert_equals 'a', 'a' } ; assert_passed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
256
|
1
|
|
|
|
|
2
|
eval { assert_equals 'a', 'b' } ; assert_failed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
120
|
|
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub test_assert_equals_array() { |
260
|
1
|
|
|
1
|
0
|
2
|
eval { Test::Extreme::assert_equals_array [ 'a', 'b' ], ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
4
|
|
261
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_array [ 'a', 'b' ], ['b', 'a'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
268
|
|
262
|
|
|
|
|
|
|
|
263
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_array [ 'a' ], ['a', 'a'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
301
|
|
264
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_array [ 'a', 'b' ], ['a'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
270
|
|
265
|
|
|
|
|
|
|
|
266
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_array 'a', [ 'a' ] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
242
|
|
267
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_array [ 'a' ], 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
256
|
|
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub test_assert_equals_hash() { |
271
|
1
|
|
|
1
|
0
|
3
|
eval { Test::Extreme::assert_equals_hash { k1=>'v1', k2=>'v2' }, { k1=>'v1', k2=>'v2' } } ; assert_passed ; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
6
|
|
272
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_hash { k1=>'v1', k2=>'v2' }, { k1=>'v1', k2=>'v3' } } ; assert_failed ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
305
|
|
273
|
|
|
|
|
|
|
|
274
|
1
|
|
|
|
|
1
|
eval { Test::Extreme::assert_equals_hash { k1=>'v1', k2=>'v2' }, { k1=>'v1' } } ; assert_failed ; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
342
|
|
275
|
|
|
|
|
|
|
|
276
|
1
|
|
|
|
|
2
|
eval { Test::Extreme::assert_equals_hash { k1=>'v1', k2=>'v2' }, ['a'] } ; assert_failed ; |
|
1
|
|
|
|
|
633
|
|
|
1
|
|
|
|
|
6
|
|
277
|
1
|
|
|
|
|
1
|
eval { Test::Extreme::assert_equals_hash { k1=>'v1', k2=>'v2' }, 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub test_assert_equals_polymorphic() { |
281
|
1
|
|
|
1
|
0
|
2
|
eval { assert_equals 'a', 'a' } ; assert_passed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
282
|
|
|
|
|
|
|
|
283
|
1
|
|
|
|
|
1
|
eval { assert_equals [ 'a', 'b' ], ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
284
|
1
|
|
|
|
|
1
|
eval { assert_equals [ 'a', 'b' ], ['b', 'a'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
339
|
|
285
|
|
|
|
|
|
|
|
286
|
1
|
|
|
|
|
1
|
eval { assert_equals { k1 => 'v1', k2 => 'v2' }, { k1 => 'v1', k2 => 'v2' } } ; assert_passed ; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
5
|
|
287
|
1
|
|
|
|
|
2
|
eval { assert_equals { k1 => 'v1', k2 => 'v2' }, { k1 => 'v1', k2 => 'v3' } } ; assert_failed ; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
338
|
|
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub test_assert_subset() { |
291
|
1
|
|
|
1
|
0
|
2
|
eval { assert_subset [ 'a' ], ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
5
|
|
292
|
1
|
|
|
|
|
2
|
eval { assert_subset ['a', 'b'], ['a', 'b', 'c'] } ; assert_passed; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
5
|
|
293
|
1
|
|
|
|
|
1
|
eval { assert_subset['a', 'b'], ['a', 'b'] } ; assert_passed; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
294
|
|
|
|
|
|
|
|
295
|
1
|
|
|
|
|
1
|
eval { assert_subset [ 'c' ], ['a', 'b'] } ; assert_failed ; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
371
|
|
296
|
1
|
|
|
|
|
2
|
eval { assert_subset [ 'a', 'c' ], ['a', 'b', 'd'] } ; assert_failed ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
376
|
|
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
sub test_assert_contains { |
300
|
1
|
|
|
1
|
0
|
2
|
eval { assert_contains 'a', ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
6
|
|
301
|
1
|
|
|
|
|
2
|
eval { assert_contains 'b', ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
302
|
1
|
|
|
|
|
1
|
eval { assert_contains 'c', ['a', 'b'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
287
|
|
303
|
1
|
|
|
|
|
2
|
eval { assert_contains '', ['a', 'b'] } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
255
|
|
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
sub test_assert_is_array { |
307
|
1
|
|
|
1
|
0
|
2
|
eval { assert_is_array ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
308
|
1
|
|
|
|
|
1
|
eval { assert_is_array {'a', 'b'} } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
237
|
|
309
|
1
|
|
|
|
|
1
|
eval { assert_is_array 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
113
|
|
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub test_assert_is_hash { |
313
|
1
|
|
|
1
|
0
|
29
|
eval { assert_is_hash {'a', 'b'} } ; assert_passed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
314
|
1
|
|
|
|
|
1
|
eval { assert_is_hash ['a', 'b'] } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
439
|
|
315
|
1
|
|
|
|
|
2
|
eval { assert_is_hash 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
112
|
|
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub test_assert_size { |
319
|
1
|
|
|
1
|
0
|
2
|
eval { assert_size 2, ['a', 'b'] } ; assert_passed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
320
|
1
|
|
|
|
|
1
|
eval { assert_size 1, ['a'] } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
321
|
1
|
|
|
|
|
2
|
eval { assert_size 0, [] } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
322
|
|
|
|
|
|
|
|
323
|
1
|
|
|
|
|
2
|
eval { assert_size 2, {'a', 'b'} } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
374
|
|
324
|
1
|
|
|
|
|
2
|
eval { assert_size 1, 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
114
|
|
325
|
|
|
|
|
|
|
} |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub test_assert_keys { |
328
|
1
|
|
|
1
|
0
|
2
|
eval { assert_keys ['a', 'b'], { a => 1, b => 2 } } ; assert_passed ; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
6
|
|
329
|
1
|
|
|
|
|
1
|
eval { assert_keys ['b', 'a'], { a => 1, b => 2 } } ; assert_passed ; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
5
|
|
330
|
1
|
|
|
|
|
2
|
eval { assert_keys ['a' ], { a => 1, b => 2 } } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
486
|
|
331
|
1
|
|
|
|
|
2
|
eval { assert_keys ['a', 'b'], { a => 1 } } ; assert_failed ; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
508
|
|
332
|
|
|
|
|
|
|
|
333
|
1
|
|
|
|
|
2
|
eval { assert_keys ['a'], ['a'] } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
313
|
|
334
|
1
|
|
|
|
|
1
|
eval { assert_keys 'a' , ['a'] } ; assert_failed ; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
307
|
|
335
|
1
|
|
|
|
|
1
|
eval { assert_keys ['a'], 'a' } ; assert_failed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
250
|
|
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub test_assert_is_string { |
339
|
1
|
|
|
1
|
0
|
2
|
eval { assert_is_string 'hello' } ; assert_passed ; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
340
|
|
|
|
|
|
|
|
341
|
1
|
|
|
|
|
2
|
eval { assert_is_string ['hello', 'world'] } ; assert_failed ; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
235
|
|
342
|
1
|
|
|
|
|
2
|
eval { assert_is_string {'hello', 'world'} } ; assert_failed ; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
237
|
|
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
|
346
|
0
|
|
|
0
|
|
0
|
package foo ; sub foo_1 { } sub foo_2 { } sub foo_3 { } |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
347
|
0
|
|
|
0
|
|
0
|
package bar ; sub bar_1 { } sub bar_2 { } sub bar_3 { } |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
348
|
|
|
|
|
|
|
package Test::Extreme; |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
sub test_list_subs { |
351
|
1
|
|
|
1
|
0
|
6
|
assert_equals [ 'foo_1', 'foo_2', 'foo_3' ], Test::Extreme::_list_subs 'main::foo::'; |
352
|
1
|
|
|
|
|
6
|
assert_equals [ 'foo_1', 'foo_2', 'foo_3' ], Test::Extreme::_list_subs 'foo::'; |
353
|
1
|
|
|
|
|
6
|
assert_equals [ 'bar_1', 'bar_2', 'bar_3' ], Test::Extreme::_list_subs 'bar::'; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
sub test_list_packages() |
357
|
|
|
|
|
|
|
{ |
358
|
1
|
|
|
1
|
0
|
5
|
my $packages = Test::Extreme::_list_packages 'main::'; |
359
|
1
|
|
|
|
|
7
|
assert_subset ['foo::', 'bar::'], $packages; |
360
|
1
|
|
|
|
|
3
|
assert_none grep { ! /::$/ } @$packages; |
|
57
|
|
|
|
|
132
|
|
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
0
|
|
|
0
|
|
0
|
package foo_test ; sub test_1 { } sub test_2 { } sub test_3 { } |
|
0
|
|
|
0
|
|
0
|
|
|
0
|
|
|
0
|
|
0
|
|
364
|
|
|
|
|
|
|
package Test::Extreme; |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
sub test_list_tests() { |
367
|
1
|
|
|
1
|
0
|
5
|
my $list = Test::Extreme::_list_tests 'foo_test::'; |
368
|
1
|
|
|
|
|
3
|
my $expected = [qw( foo_test::test_1 foo_test::test_2 foo_test::test_3 )]; |
369
|
1
|
|
|
|
|
4
|
assert_equals $expected, $list; |
370
|
|
|
|
|
|
|
} |
371
|
|
|
|
|
|
|
|
372
|
1
|
|
|
1
|
0
|
4
|
sub this_will_pass { assert_true 1 } |
373
|
1
|
|
|
1
|
0
|
5
|
sub this_will_fail { assert_true 0 } |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
sub test_execute_tests { |
376
|
1
|
|
|
1
|
0
|
4
|
my $all_tests = ['Test::Extreme::this_will_pass', 'Test::Extreme::this_will_fail']; |
377
|
1
|
|
|
|
|
2
|
my $failure_messages = { }; |
378
|
1
|
|
|
|
|
6
|
Test::Extreme::_execute_tests $all_tests, $failure_messages, 0; |
379
|
1
|
|
|
|
|
5
|
assert_keys ['Test::Extreme::this_will_fail'], $failure_messages; |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
run_tests_as_script 'Test::Extreme' if $0 =~ /Extreme.pm$/; |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
385
|
|
|
|
|
|
|
# TESTS END |
386
|
|
|
|
|
|
|
#----------------------------------------------------------------- |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
1; |
389
|
|
|
|
|
|
|
__END__ |