line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Pcuke::Gherkin::Node; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
1197
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
419
|
|
4
|
11
|
|
|
11
|
|
57
|
use strict; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
366
|
|
5
|
|
|
|
|
|
|
|
6
|
11
|
|
|
11
|
|
64
|
use Scalar::Util qw(refaddr); |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
614
|
|
7
|
11
|
|
|
11
|
|
60
|
use Carp; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
7547
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Test::Pcuke::Gherkin::Node - Base class for Gherkin nodes |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package MyClass; |
16
|
|
|
|
|
|
|
use base 'Test::Pcuke::Gherkin::Node'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
|
|
|
|
|
|
my ($class, %args) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @properties = qw{property1 property2}; |
22
|
|
|
|
|
|
|
my @immutable_properties = qw{immutable1 immutable2}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return $class->SUPER::new( |
25
|
|
|
|
|
|
|
immutable_properties => [ @immutable_properties ], |
26
|
|
|
|
|
|
|
properties => [ @properties ], |
27
|
|
|
|
|
|
|
args => {%args} |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub set_property1 { |
32
|
|
|
|
|
|
|
my ($self, $value) = @_; |
33
|
|
|
|
|
|
|
$self->_set_property('property1', $value); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub property1 { $_[0]->_get_property('property1'); } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#... etc. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my %properties = (); |
47
|
|
|
|
|
|
|
my %immutables = (); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
54
|
72
|
|
|
72
|
1
|
2099
|
my ($class, %conf) = @_; |
55
|
|
|
|
|
|
|
|
56
|
72
|
|
|
|
|
104
|
my $self = bless \do { my $anonymous_scalar }, $class; |
|
72
|
|
|
|
|
279
|
|
57
|
|
|
|
|
|
|
|
58
|
72
|
100
|
|
|
|
247
|
return $self |
59
|
|
|
|
|
|
|
unless %conf; |
60
|
|
|
|
|
|
|
|
61
|
67
|
|
|
|
|
116
|
my $args = $conf{args}; |
62
|
67
|
100
|
|
|
|
176
|
return $self |
63
|
|
|
|
|
|
|
unless $args; |
64
|
|
|
|
|
|
|
|
65
|
59
|
100
|
|
|
|
428
|
if ( ref $conf{properties} eq 'ARRAY' ) { |
66
|
34
|
|
|
|
|
54
|
foreach my $name ( @{ $conf{properties} } ) { |
|
34
|
|
|
|
|
94
|
|
67
|
89
|
100
|
|
|
|
386
|
$self->_set_property( $name, $args->{$name} ) |
68
|
|
|
|
|
|
|
if defined $args->{$name}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
59
|
50
|
|
|
|
196
|
if ( ref $conf{immutables} eq 'ARRAY' ) { |
73
|
59
|
|
|
|
|
79
|
foreach my $name ( @{ $conf{immutables} } ) { |
|
59
|
|
|
|
|
133
|
|
74
|
189
|
100
|
|
|
|
562
|
$self->_set_immutable($name, $args->{$name}) |
75
|
|
|
|
|
|
|
if defined $args->{$name}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
59
|
|
|
|
|
221
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub DESTROY { |
83
|
87
|
|
|
87
|
|
76285
|
my $key = refaddr shift; |
84
|
87
|
|
|
|
|
337
|
delete $properties{$key}; |
85
|
87
|
|
|
|
|
1915
|
delete $immutables{$key}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _set_property { |
89
|
177
|
|
|
177
|
|
319
|
my ($self, $name, $value) = @_; |
90
|
177
|
|
|
|
|
344
|
my $key = refaddr $self; |
91
|
177
|
|
|
|
|
976
|
$properties{$key}->{$name} = $value; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _set_immutable { |
95
|
101
|
|
|
101
|
|
232
|
my ($self, $name, $value) = @_; |
96
|
|
|
|
|
|
|
|
97
|
101
|
|
|
|
|
376
|
my $key = refaddr $self; |
98
|
|
|
|
|
|
|
|
99
|
101
|
100
|
|
|
|
392
|
if ( defined $immutables{$key}->{$name} ) { |
100
|
13
|
|
|
|
|
265
|
confess ref($self) . "::$name is an immutable property and can not be changed"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
88
|
|
100
|
|
|
453
|
$immutables{$key}->{$name} = $value || q{}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _get_property { |
108
|
169
|
|
|
169
|
|
315
|
my ($self, $name) = @_; |
109
|
169
|
|
|
|
|
390
|
my $key = refaddr $self; |
110
|
169
|
|
|
|
|
750
|
$properties{$key}->{$name}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _get_immutable { |
114
|
95
|
|
|
95
|
|
159
|
my ($self, $name) = @_; |
115
|
95
|
|
|
|
|
223
|
my $key = refaddr $self; |
116
|
95
|
|
|
|
|
710
|
$immutables{$key}->{$name}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _add_property { |
122
|
38
|
|
|
38
|
|
132
|
my ($self, $name, $value) = @_; |
123
|
|
|
|
|
|
|
|
124
|
38
|
100
|
|
|
|
133
|
confess "scenario must be defined" |
125
|
|
|
|
|
|
|
unless $value; |
126
|
|
|
|
|
|
|
|
127
|
36
|
|
|
|
|
208
|
my $values = $self->_get_property($name); |
128
|
36
|
|
|
|
|
82
|
push @$values, $value; |
129
|
36
|
|
|
|
|
95
|
$self->_set_property($name, $values); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; # End of Test::Pcuke::Gherkin::Node |
134
|
|
|
|
|
|
|
__END__ |