line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
6
|
use utf8; # Interpret funky German chars in regexes properly |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
41
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
216
|
use Test::BDD::Cucumber::StepFile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1109
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
446
|
use lib 'examples/calculator/lib/'; |
|
1
|
|
|
|
|
706
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Before sub { |
13
|
1
|
|
|
1
|
|
871
|
use_ok('Calculator'); |
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
16
|
|
|
1
|
|
|
1
|
|
242
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
16
|
|
|
1
|
|
|
1
|
|
278
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
17
|
|
|
1
|
|
|
1
|
|
199
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
1
|
|
22
|
|
|
1
|
|
|
1
|
|
274
|
|
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
1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
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
265
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
246
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
187
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
222
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
177
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
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
|
|
|
|
|
|
|
}; |