line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Test::More; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
237
|
use Test::BDD::Cucumber::StepFile; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1146
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use lib 'examples/calculator/lib/'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Before sub { |
12
|
1
|
|
|
1
|
|
219
|
use_ok('Calculator'); |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
17
|
|
|
1
|
|
|
1
|
|
174
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
13
|
|
|
1
|
|
|
1
|
|
160
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
13
|
|
|
1
|
|
|
1
|
|
190
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
31
|
|
|
1
|
|
|
1
|
|
190
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
66
|
|
|
1
|
|
|
1
|
|
183
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
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|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
180
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
195
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
179
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
264
|
|
|
1
|
|
|
|
|
172
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
After sub { |
16
|
|
|
|
|
|
|
my $c = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# a bit contrived, as garbage collection would clear it out |
19
|
|
|
|
|
|
|
delete $c->stash->{'scenario'}->{'Calculator'}; |
20
|
|
|
|
|
|
|
ok( ( not exists $c->stash->{'scenario'}->{'Calculator'} ), |
21
|
|
|
|
|
|
|
"Calculator cleaned up" ); |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %numbers_as_words = ( |
25
|
|
|
|
|
|
|
__THE_NUMBER_ONE__ => 1, |
26
|
|
|
|
|
|
|
__THE_NUMBER_FOUR__ => 4, |
27
|
|
|
|
|
|
|
__THE_NUMBER_FIVE__ => 5, |
28
|
|
|
|
|
|
|
__THE_NUMBER_TEN__ => 10, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub map_word_to_number { |
32
|
10
|
|
|
10
|
0
|
24
|
my $word = shift; |
33
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
58
|
ok( $word, "Passed in a word to map [$word]" ); |
35
|
10
|
|
|
|
|
3521
|
ok( exists $numbers_as_words{$word}, "Mapping found" ); |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
3487
|
return $numbers_as_words{$word}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Transform qr/^(__THE_NUMBER_\w+__)$/, sub { map_word_to_number($1) }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Transform qr/^table:number as word$/, sub { |
43
|
|
|
|
|
|
|
my ( $c, $data ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
for my $row ( @{$data} ) { |
46
|
|
|
|
|
|
|
$row->{'number'} = map_word_to_number( $row->{'number as word'} ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Given 'a new Calculator object', sub { |
51
|
|
|
|
|
|
|
S->{'Calculator'} = Calculator->new(); |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Given qr/^having pressed (.+)/, sub { |
55
|
|
|
|
|
|
|
S->{'Calculator'}->press($_) for split( /(,| and) /, C->matches->[0] ); |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Given qr/^having keyed (.+)/, sub { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Make this call the having pressed |
61
|
|
|
|
|
|
|
my ($value) = @{ C->matches }; |
62
|
|
|
|
|
|
|
S->{'Calculator'}->key_in($value); |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Given 'having successfully performed the following calculations', sub { |
66
|
|
|
|
|
|
|
my $calculator = S->{'Calculator'}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
for my $row ( @{ C->data } ) { |
69
|
|
|
|
|
|
|
C->dispatch( 'Given', 'having keyed ' . $row->{'first'} ); |
70
|
|
|
|
|
|
|
C->dispatch( 'Given', 'having keyed ' . $row->{'operator'} ); |
71
|
|
|
|
|
|
|
C->dispatch( 'Given', 'having keyed ' . $row->{'second'} ); |
72
|
|
|
|
|
|
|
C->dispatch( 'Given', 'having pressed =' ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
is( $calculator->display, $row->{'result'}, |
75
|
|
|
|
|
|
|
$row->{'first'} . ' ' |
76
|
|
|
|
|
|
|
. $row->{'operator'} . ' ' |
77
|
|
|
|
|
|
|
. $row->{'second'} ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Given 'having entered the following sequence', sub { |
82
|
|
|
|
|
|
|
S->{'Calculator'}->key_in( C->data ); |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Given 'having added these numbers', sub { |
86
|
|
|
|
|
|
|
for my $row ( @{ C->data } ) { |
87
|
|
|
|
|
|
|
S->{'Calculator'}->key_in( $row->{number} ); |
88
|
|
|
|
|
|
|
S->{'Calculator'}->key_in('+'); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Then qr/^the display should show (.+)/, sub { |
93
|
|
|
|
|
|
|
my ($value) = @{ C->matches }; |
94
|
|
|
|
|
|
|
is( S->{'Calculator'}->display, $value, "Calculator display as expected" ); |
95
|
|
|
|
|
|
|
}; |