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
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Test::More; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
234
|
use Test::BDD::Cucumber::StepFile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1212
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
9
|
use lib 'examples/calculator/lib/'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Before sub { |
12
|
1
|
|
|
1
|
|
238
|
use_ok('Calculator'); |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
15
|
|
|
1
|
|
|
1
|
|
183
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
13
|
|
|
1
|
|
|
1
|
|
183
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
13
|
|
|
1
|
|
|
1
|
|
202
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
14
|
|
|
1
|
|
|
1
|
|
178
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
65
|
|
|
1
|
|
|
1
|
|
180
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
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|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
198
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
205
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
214
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
166
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
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
|
28
|
my $word = shift; |
33
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
57
|
ok( $word, "Passed in a word to map [$word]" ); |
35
|
10
|
|
|
|
|
3494
|
ok( exists $numbers_as_words{$word}, "Mapping found" ); |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
3495
|
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
|
|
|
|
|
|
|
}; |