| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
6094
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
62
|
|
|
2
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
113
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Test::Expectation; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 0.06; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
181
|
|
|
9
|
2
|
|
|
2
|
|
2367
|
use Test::More 'no_plan'; |
|
|
2
|
|
|
|
|
47850
|
|
|
|
2
|
|
|
|
|
21
|
|
|
10
|
2
|
|
|
2
|
|
1595
|
use Test::Expectation::Positive; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
57
|
|
|
11
|
2
|
|
|
2
|
|
773
|
use Test::Expectation::Negative; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
57
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
|
14
|
2
|
|
|
2
|
|
11
|
use vars qw(@EXPORT @ISA); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
976
|
|
|
15
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
16
|
|
|
|
|
|
|
@EXPORT = qw(it_should before_each after_each it_is_a); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @Expectations; |
|
19
|
|
|
|
|
|
|
our $Description = ''; |
|
20
|
|
|
|
|
|
|
our $BeforeEach = sub {}; |
|
21
|
|
|
|
|
|
|
our $AfterEach = sub {}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub it_is_a { |
|
24
|
1
|
|
|
1
|
0
|
9
|
$Description = shift; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub before_each { |
|
28
|
1
|
|
|
1
|
0
|
8
|
$BeforeEach = shift; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub after_each { |
|
32
|
1
|
|
|
1
|
0
|
10
|
$AfterEach = shift; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub it_should { |
|
36
|
5
|
|
|
5
|
0
|
34
|
my ($testName, $testRef) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
8
|
@Expectations = (); |
|
39
|
5
|
|
|
|
|
10
|
$BeforeEach->(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
42
|
$testRef->(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
1099
|
$AfterEach->(); |
|
44
|
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
24
|
foreach my $expectation (@Expectations) { |
|
46
|
6
|
50
|
|
|
|
210
|
my $testString = ($Description ? $Description . " " : 'it ') . "should $testName"; |
|
47
|
|
|
|
|
|
|
|
|
48
|
6
|
50
|
|
|
|
21
|
if ($expectation->isMet()) { |
|
49
|
6
|
|
|
|
|
16
|
pass($testString); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
else { |
|
52
|
0
|
|
|
|
|
0
|
fail($testString . ' (' . $expectation->failure . ')'); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
5
|
|
|
|
|
1225
|
@Expectations = (); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
*UNIVERSAL::_bindExpectation = sub { |
|
60
|
6
|
|
|
6
|
|
9
|
my ($expectationType, $class, $method) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
36
|
my $expectation = $expectationType->new($class, $method); |
|
63
|
|
|
|
|
|
|
|
|
64
|
6
|
|
|
|
|
8
|
push(@Expectations, $expectation); |
|
65
|
6
|
|
|
|
|
25
|
return $expectation |
|
66
|
|
|
|
|
|
|
}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
*UNIVERSAL::expects = sub { |
|
69
|
5
|
|
|
5
|
|
23
|
UNIVERSAL::_bindExpectation('Test::Expectation::Positive', @_); |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
*UNIVERSAL::does_not_expect = sub { |
|
73
|
1
|
|
|
1
|
|
9
|
UNIVERSAL::_bindExpectation('Test::Expectation::Negative', @_); |
|
74
|
|
|
|
|
|
|
}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |