line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
6
|
use utf8; # Interpret funky German chars in regexes properly |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
24
|
use Test::More; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
213
|
use Test::BDD::Cucumber::StepFile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1135
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
463
|
use lib 'examples/calculator/lib/'; |
|
1
|
|
|
|
|
730
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Before sub { |
13
|
1
|
|
|
1
|
|
786
|
use_ok('Calculator'); |
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
16
|
|
|
1
|
|
|
1
|
|
224
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
15
|
|
|
1
|
|
|
1
|
|
300
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
1
|
|
|
1
|
|
|
1
|
|
40
|
|
|
1
|
|
|
1
|
|
184
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
15
|
|
|
1
|
|
|
1
|
|
188
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1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
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
247
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
231
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
240
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
228
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
187
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
After sub { |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# a bit contrived, as garbage collection would clear it out |
19
|
|
|
|
|
|
|
delete S->{'Calculator'}; |
20
|
|
|
|
|
|
|
ok( not exists S->{'Calculator'} ); |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my %numbers_as_words = ( |
24
|
|
|
|
|
|
|
__THE_NUMBER_ONE__ => 1, |
25
|
|
|
|
|
|
|
__THE_NUMBER_FOUR__ => 4, |
26
|
|
|
|
|
|
|
__THE_NUMBER_FIVE__ => 5, |
27
|
|
|
|
|
|
|
__THE_NUMBER_TEN__ => 10, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub map_word_to_number_i18n { |
31
|
0
|
|
|
0
|
0
|
|
my $word = shift; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
ok($word); |
34
|
0
|
|
|
|
|
|
ok( exists $numbers_as_words{$word} ); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $numbers_as_words{$word}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Transform qr/^(__THE_NUMBER_\w+__)$/, sub { map_word_to_number_i18n($1) }; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Transform qr/^table:number as word$/, sub { |
42
|
|
|
|
|
|
|
my ( $c, $data ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
for my $row ( @{$data} ) { |
45
|
|
|
|
|
|
|
$row->{'number'} = map_word_to_number_i18n( $row->{'number as word'} ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Gegebensei 'ein neues Objekt der Klasse Calculator', sub { |
50
|
|
|
|
|
|
|
S->{'Calculator'} = Calculator->new(); |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Wenn qr/^ich (.+) gedrückt habe/, sub { |
54
|
|
|
|
|
|
|
S->{'Calculator'}->press($_) for split( /(,| und) /, C->matches->[0] ); |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Wenn qr/^die Tasten (.+) gedrückt wurden/, sub { |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Make this call the having pressed |
60
|
|
|
|
|
|
|
my ($value) = @{ C->matches }; |
61
|
|
|
|
|
|
|
S->{'Calculator'}->key_in($value); |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Wenn 'ich erfolgreich folgende Rechnungen durchgeführt habe', sub { |
65
|
|
|
|
|
|
|
my $calculator = S->{'Calculator'}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
for my $row ( @{ C->data } ) { |
68
|
|
|
|
|
|
|
$calculator->key_in( $row->{'first'} ); |
69
|
|
|
|
|
|
|
$calculator->key_in( $row->{'operator'} ); |
70
|
|
|
|
|
|
|
$calculator->key_in( $row->{'second'} ); |
71
|
|
|
|
|
|
|
$calculator->press('='); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
is( $calculator->display, $row->{'result'}, |
74
|
|
|
|
|
|
|
$row->{'first'} . ' ' |
75
|
|
|
|
|
|
|
. $row->{'operator'} . ' ' |
76
|
|
|
|
|
|
|
. $row->{'second'} ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Wenn 'ich folgende Zeichenfolge eingegeben habe', sub { |
81
|
|
|
|
|
|
|
S->{'Calculator'}->key_in( C->data ); |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Wenn 'ich folgende Zahlen addiert habe', sub { |
85
|
|
|
|
|
|
|
for my $row ( @{ C->data } ) { |
86
|
|
|
|
|
|
|
S->{'Calculator'}->key_in( $row->{number} ); |
87
|
|
|
|
|
|
|
S->{'Calculator'}->key_in('+'); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Dann qr/^ist auf der Anzeige (.+) zu sehen/, sub { |
92
|
|
|
|
|
|
|
my ($value) = @{ C->matches }; |
93
|
|
|
|
|
|
|
is( S->{'Calculator'}->display, $value, "Calculator display as expected" ); |
94
|
|
|
|
|
|
|
}; |