line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Given; |
2
|
41
|
|
|
41
|
|
21705
|
use strict; |
|
41
|
|
|
|
|
72
|
|
|
41
|
|
|
|
|
1282
|
|
3
|
41
|
|
|
41
|
|
195
|
use warnings; |
|
41
|
|
|
|
|
61
|
|
|
41
|
|
|
|
|
1032
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
22540
|
use Test::Given::Context; |
|
41
|
|
|
|
|
201
|
|
|
41
|
|
|
|
|
2367
|
|
6
|
41
|
|
|
41
|
|
248
|
use Test::Given::Builder; |
|
41
|
|
|
|
|
69
|
|
|
41
|
|
|
|
|
183
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
41
|
|
|
41
|
|
6144
|
require Exporter; |
10
|
41
|
|
|
|
|
704
|
our @ISA = qw(Exporter); |
11
|
41
|
|
|
|
|
834
|
our @EXPORT = qw(describe context Given When Then And Invariant onDone has_failed); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
41
|
|
|
41
|
|
34493
|
use version; our $VERSION = qv('0.3.1'); |
|
41
|
|
|
|
|
90927
|
|
|
41
|
|
|
|
|
237
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $context = Test::Given::Context->new('** TOPLEVEL **'); |
17
|
|
|
|
|
|
|
sub describe { |
18
|
93
|
|
|
93
|
0
|
95237
|
my ($description, $sub) = @_; |
19
|
93
|
|
|
|
|
639
|
$context = $context->add_context($description); |
20
|
93
|
|
|
|
|
279
|
$sub->(); |
21
|
90
|
|
|
|
|
327
|
$context = $context->parent(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
*context = \&describe; |
24
|
|
|
|
|
|
|
|
25
|
99
|
|
|
99
|
1
|
894
|
sub Given { $context->add_given(@_) } |
26
|
20
|
|
|
20
|
1
|
173
|
sub When { $context->add_when(@_) } |
27
|
29
|
|
|
29
|
1
|
260
|
sub Invariant { $context->add_invariant(@_) } |
28
|
133
|
|
|
133
|
1
|
1045
|
sub Then { $context->add_then(@_) } |
29
|
8
|
|
|
8
|
1
|
59
|
sub onDone { $context->add_done(@_) } |
30
|
82
|
|
|
82
|
1
|
665
|
sub And { $context->add_and(@_) } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub has_failed { |
33
|
5
|
|
|
5
|
1
|
37
|
my ($exceptions, $re) = @_; |
34
|
5
|
50
|
33
|
|
|
28
|
return '' unless $exceptions and $re; |
35
|
5
|
|
|
|
|
12
|
grep { $_ =~ $re } @$exceptions; |
|
8
|
|
|
|
|
37
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
END { |
39
|
41
|
|
|
41
|
|
269
|
plan(tests => $context->test_count()); |
40
|
39
|
|
|
|
|
13533
|
$context->run_tests(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |