line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
24
|
|
|
24
|
|
13602
|
use Test::Builder; |
|
24
|
|
|
|
|
172180
|
|
|
24
|
|
|
|
|
651
|
|
2
|
24
|
|
|
24
|
|
481
|
use TestML::Runtime; |
|
24
|
|
|
|
|
28
|
|
|
24
|
|
|
|
|
583
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package TestML::Runtime::TAP; |
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
78
|
use TestML::Base; |
|
24
|
|
|
|
|
26
|
|
|
24
|
|
|
|
|
117
|
|
7
|
|
|
|
|
|
|
extends 'TestML::Runtime'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has tap_object => sub { Test::Builder->new }; |
10
|
|
|
|
|
|
|
has planned => 0; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub run { |
13
|
23
|
|
|
23
|
0
|
43
|
my ($self) = @_; |
14
|
23
|
|
|
|
|
130
|
$self->SUPER::run; |
15
|
23
|
|
|
|
|
54
|
$self->check_plan; |
16
|
23
|
|
|
|
|
61
|
$self->plan_end; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub run_assertion { |
20
|
121
|
|
|
121
|
0
|
144
|
my ($self, @args) = @_; |
21
|
121
|
|
|
|
|
200
|
$self->check_plan; |
22
|
121
|
|
|
|
|
371
|
$self->SUPER::run_assertion(@args); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub check_plan { |
26
|
144
|
|
|
144
|
0
|
137
|
my ($self) = @_; |
27
|
144
|
100
|
|
|
|
267
|
if (! $self->planned) { |
28
|
23
|
|
|
|
|
105
|
$self->title; |
29
|
23
|
|
|
|
|
1413
|
$self->plan_begin; |
30
|
23
|
|
|
|
|
4861
|
$self->{planned} = 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub title { |
35
|
23
|
|
|
23
|
0
|
30
|
my ($self) = @_; |
36
|
23
|
100
|
|
|
|
61
|
if (my $title = $self->function->getvar('Title')) { |
37
|
6
|
|
|
|
|
29
|
$title = $title->value; |
38
|
6
|
|
|
|
|
17
|
$title = "=== $title ===\n"; |
39
|
6
|
|
|
|
|
17
|
$self->tap_object->note($title); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub skip_test { |
44
|
0
|
|
|
0
|
0
|
0
|
my ($self, $reason) = @_; |
45
|
0
|
|
|
|
|
0
|
$self->tap_object->plan(skip_all => $reason); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub plan_begin { |
49
|
23
|
|
|
23
|
0
|
39
|
my ($self) = @_; |
50
|
23
|
100
|
|
|
|
59
|
if (my $tests = $self->function->getvar('Plan')) { |
51
|
22
|
|
|
|
|
62
|
$self->tap_object->plan(tests => $tests->value); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub plan_end { |
56
|
23
|
|
|
23
|
0
|
31
|
my ($self) = @_; |
57
|
23
|
|
|
|
|
84
|
$self->tap_object->done_testing(); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# TODO Use Test::Diff here. |
61
|
|
|
|
|
|
|
sub assert_EQ { |
62
|
96
|
|
|
96
|
0
|
108
|
my ($self, $got, $want) = @_; |
63
|
96
|
|
|
|
|
189
|
$got = $got->str->value; |
64
|
96
|
|
|
|
|
176
|
$want = $want->str->value; |
65
|
96
|
50
|
33
|
|
|
241
|
if ($got ne $want and $want =~ /\n/) { |
66
|
0
|
|
|
|
|
0
|
my $block = $self->function->getvar('Block'); |
67
|
0
|
|
|
|
|
0
|
my $diff = $self->function->getvar('Diff'); |
68
|
0
|
0
|
0
|
|
|
0
|
if ($diff or exists $block->points->{DIFF}) { |
69
|
0
|
|
|
|
|
0
|
require Text::Diff; |
70
|
0
|
|
|
|
|
0
|
$self->tap_object->ok(0, $self->get_label); |
71
|
0
|
|
|
|
|
0
|
my $diff = Text::Diff::diff( |
72
|
|
|
|
|
|
|
\$want, \$got, { |
73
|
|
|
|
|
|
|
FILENAME_A => "want", |
74
|
|
|
|
|
|
|
FILENAME_B => "got", |
75
|
|
|
|
|
|
|
}, |
76
|
|
|
|
|
|
|
); |
77
|
0
|
|
|
|
|
0
|
$self->tap_object->diag($diff); |
78
|
0
|
|
|
|
|
0
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
$self->tap_object->is_eq( |
82
|
96
|
|
|
|
|
173
|
$got, |
83
|
|
|
|
|
|
|
$want, |
84
|
|
|
|
|
|
|
$self->get_label, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub assert_HAS { |
89
|
7
|
|
|
7
|
0
|
11
|
my ($self, $got, $has) = @_; |
90
|
7
|
|
|
|
|
19
|
$got = $got->str->value; |
91
|
7
|
|
|
|
|
16
|
$has = $has->str->value; |
92
|
7
|
|
|
|
|
20
|
my $assertion = (index($got, $has) >= 0); |
93
|
7
|
50
|
|
|
|
14
|
if (not $assertion) { |
94
|
0
|
|
|
|
|
0
|
my $msg = <<"..."; |
95
|
|
|
|
|
|
|
Failed TestML HAS (~~) assertion. This text: |
96
|
|
|
|
|
|
|
'$got' |
97
|
|
|
|
|
|
|
does not contain this string: |
98
|
|
|
|
|
|
|
'$has' |
99
|
|
|
|
|
|
|
... |
100
|
0
|
|
|
|
|
0
|
$self->tap_object->diag($msg); |
101
|
|
|
|
|
|
|
} |
102
|
7
|
|
|
|
|
16
|
$self->tap_object->ok($assertion, $self->get_label); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub assert_OK { |
106
|
18
|
|
|
18
|
0
|
22
|
my ($self, $got) = @_; |
107
|
18
|
|
|
|
|
28
|
$self->tap_object->ok( |
108
|
|
|
|
|
|
|
$got->bool->value, |
109
|
|
|
|
|
|
|
$self->get_label, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |