examples/i18n_de/features/step_definitions/calculator_steps.pl

filter: Statementstmt 100% 255 / 255 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 66 / 66 Podpod 0.0% 0 / 1 totaltotal 99.6% 321 / 322 CC 5 SCAR 1.1
CC
5
Cov
100%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.1
« examples/calculator/features/step_definitions/calculator_steps.pl ↑ Summary blib/lib/Test/BDD/Cucumber/Model/Dataset.pm »
1 #!perl
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8; # Interpret funky German chars in regexes properly
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Test::BDD::Cucumber::StepFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use lib 'examples/calculator/lib/';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 60 ▶Before sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
13 2 ▶ use_ok('Calculator');
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 };
15  
16 60 ▶After sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 # a bit contrived, as garbage collection would clear it out
19 60 delete S->{'Calculator'};
20 60 ok( not exists S->{'Calculator'} );
21 2 };
22  
23 2 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 15 ▶sub map_word_to_number_i18n {
Subroutine map_word_to_number_i18n: called CC=1 SCAR=0.0
Pod undocumented
31 15 my $word = shift;
32  
33 15 ok($word);
34 15 ok( exists $numbers_as_words{$word} );
35  
36 15 return $numbers_as_words{$word};
37 }
38  
39 6 ▶Transform qr/^(__THE_NUMBER_\w+__)$/, sub { map_word_to_number_i18n($1) };
Subroutine __ANON__: called CC=1 SCAR=0.0
40  
41 3 ▶Transform qr/^table:number as word$/, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
42 3 my ( $c, $data ) = @_;
43  
44 3 for my $row ( @{$data} ) {
45 9 $row->{'number'} = map_word_to_number_i18n( $row->{'number as word'} );
46 }
47 2 };
48  
49 24 ▶Gegebensei 'ein neues Objekt der Klasse Calculator', sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
50 24 S->{'Calculator'} = Calculator->new();
51 2 };
52  
53 20 ▶Wenn qr/^ich (.+) gedrückt habe/, sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
54 20 S->{'Calculator'}->press($_) for split( /(,| und) /, C->matches->[0] );
55 2 };
56  
57 26 ▶Wenn qr/^die Tasten (.+) gedrückt wurden/, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
58  
59 # Make this call the having pressed
60 26 my ($value) = @{ C->matches };
61 26 S->{'Calculator'}->key_in($value);
62 2 };
63  
64 2 ▶Wenn 'ich erfolgreich folgende Rechnungen durchgeführt habe', sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
65 2 my $calculator = S->{'Calculator'};
66  
67 2 for my $row ( @{ C->data } ) {
68 6 $calculator->key_in( $row->{'first'} );
69 6 $calculator->key_in( $row->{'operator'} );
70 6 $calculator->key_in( $row->{'second'} );
71 6 $calculator->press('=');
72  
73 is( $calculator->display, $row->{'result'},
74 $row->{'first'} . ' '
75 . $row->{'operator'} . ' '
76 6 . $row->{'second'} );
77 }
78 2 };
79  
80 2 ▶Wenn 'ich folgende Zeichenfolge eingegeben habe', sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
81 2 S->{'Calculator'}->key_in( C->data );
82 2 };
83  
84 2 ▶Wenn 'ich folgende Zahlen addiert habe', sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
85 2 for my $row ( @{ C->data } ) {
86 6 S->{'Calculator'}->key_in( $row->{number} );
87 6 S->{'Calculator'}->key_in('+');
88 }
89 2 };
90  
91 24 ▶Dann qr/^ist auf der Anzeige (.+) zu sehen/, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
92 24 my ($value) = @{ C->matches };
93 24 is( S->{'Calculator'}->display, $value, "Calculator display as expected" );
94 2 };
« examples/calculator/features/step_definitions/calculator_steps.pl ↑ Summary blib/lib/Test/BDD/Cucumber/Model/Dataset.pm »