line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Given::Aspect; |
2
|
41
|
|
|
41
|
|
232
|
use strict; |
|
41
|
|
|
|
|
92
|
|
|
41
|
|
|
|
|
2111
|
|
3
|
41
|
|
|
41
|
|
399
|
use warnings; |
|
41
|
|
|
|
|
79
|
|
|
41
|
|
|
|
|
1441
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
258
|
use Test::Given::Context qw(define_var); |
|
41
|
|
|
|
|
85
|
|
|
41
|
|
|
|
|
26403
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
148
|
|
|
148
|
0
|
262
|
my ($class, $sub, $name, $package) = @_; |
9
|
148
|
|
|
|
|
494
|
my $self = { |
10
|
|
|
|
|
|
|
real_sub => $sub, |
11
|
|
|
|
|
|
|
var_name => $name, |
12
|
|
|
|
|
|
|
var_package => $package, |
13
|
|
|
|
|
|
|
}; |
14
|
148
|
|
|
|
|
324
|
$self->{wrapped_sub} = wrap_sub($self); |
15
|
148
|
|
|
|
|
910
|
bless $self, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub wrap_sub { |
19
|
148
|
|
|
148
|
0
|
192
|
my ($self) = @_; |
20
|
148
|
|
|
|
|
224
|
my $sub = $self->{real_sub}; |
21
|
148
|
|
|
|
|
226
|
my $name = $self->{var_name}; |
22
|
148
|
100
|
|
|
|
322
|
if ( defined $name ) { |
23
|
106
|
|
|
|
|
215
|
my $package = "$self->{var_package}::"; |
24
|
106
|
100
|
|
|
|
668
|
if ( $name =~ s/^\@// ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return sub { |
26
|
2
|
|
|
2
|
|
6
|
define_var($package, $name, [ $sub->() ]); |
27
|
|
|
|
|
|
|
} |
28
|
2
|
|
|
|
|
10
|
} |
29
|
|
|
|
|
|
|
elsif ( $name =~ s/^\%// ) { |
30
|
|
|
|
|
|
|
return sub { |
31
|
2
|
|
|
2
|
|
7
|
define_var($package, $name, { $sub->() }); |
32
|
|
|
|
|
|
|
} |
33
|
2
|
|
|
|
|
8
|
} |
34
|
|
|
|
|
|
|
elsif ( $name =~ s/^\&// ) { |
35
|
|
|
|
|
|
|
return sub { |
36
|
29
|
|
|
29
|
|
77
|
define_var($package, $name, $sub->()); |
37
|
|
|
|
|
|
|
} |
38
|
11
|
|
|
|
|
64
|
} |
39
|
91
|
|
|
|
|
142
|
$name =~ s/^\$//; |
40
|
|
|
|
|
|
|
return sub { |
41
|
212
|
|
|
212
|
|
583
|
define_var($package, $name, \$sub->()); |
42
|
|
|
|
|
|
|
} |
43
|
91
|
|
|
|
|
517
|
} |
44
|
42
|
|
|
|
|
77
|
return $sub; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
303
|
|
|
303
|
0
|
963
|
sub apply { shift->{wrapped_sub}->() }; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Test::Given::Given; |
50
|
41
|
|
|
41
|
|
244
|
use parent 'Test::Given::Aspect'; |
|
41
|
|
|
|
|
79
|
|
|
41
|
|
|
|
|
257
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Test::Given::When; |
53
|
41
|
|
|
41
|
|
2924
|
use parent 'Test::Given::Aspect'; |
|
41
|
|
|
|
|
81
|
|
|
41
|
|
|
|
|
234
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
package Test::Given::Done; |
56
|
41
|
|
|
41
|
|
2293
|
use parent 'Test::Given::Aspect'; |
|
41
|
|
|
|
|
77
|
|
|
41
|
|
|
|
|
167
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |