line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
16
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
223
|
use Test::BDD::Cucumber::StepFile; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1187
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
12
|
use lib 'examples/calculator/lib/'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Before sub { |
12
|
1
|
|
|
1
|
|
226
|
use_ok('Calculator'); |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
20
|
|
|
1
|
|
|
1
|
|
189
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
1
|
|
14
|
|
|
1
|
|
|
1
|
|
184
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
1
|
|
12
|
|
|
1
|
|
|
1
|
|
181
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
13
|
|
|
1
|
|
|
1
|
|
181
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
20
|
|
|
1
|
|
|
1
|
|
197
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
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|
|
|
12
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
184
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
256
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
190
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
181
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
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
|
25
|
my $word = shift; |
33
|
|
|
|
|
|
|
|
34
|
10
|
|
|
|
|
60
|
ok( $word, "Passed in a word to map [$word]" ); |
35
|
10
|
|
|
|
|
3834
|
ok( exists $numbers_as_words{$word}, "Mapping found" ); |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
3491
|
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
|
|
|
|
|
|
|
}; |