line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Role::MethodReturns; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
123375
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
599
|
use Function::Parameters; |
|
1
|
|
|
|
|
3624
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
returns |
15
|
|
|
|
|
|
|
returns_maybe |
16
|
|
|
|
|
|
|
returns_self |
17
|
|
|
|
|
|
|
returns_maybe_self |
18
|
|
|
|
|
|
|
returns_object_does_interface |
19
|
|
|
|
|
|
|
returns_maybe_object_does_interface |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
981
|
use Import::Into; |
|
1
|
|
|
|
|
2841
|
|
|
1
|
|
|
|
|
36
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
533
|
use Type::Params qw/Invocant/; |
|
1
|
|
|
|
|
92232
|
|
|
1
|
|
|
|
|
10
|
|
26
|
1
|
|
|
1
|
|
271
|
use Types::Standard qw/ClassName Object Maybe/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
27
|
1
|
|
|
1
|
|
1268
|
use Types::Interface qw/ObjectDoesInterface/; |
|
1
|
|
|
|
|
44279
|
|
|
1
|
|
|
|
|
11
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub returns { |
32
|
0
|
|
|
0
|
1
|
0
|
my $type_constraint = shift; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
$type_constraint->assert_return(@_) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub returns_maybe { |
40
|
0
|
|
|
0
|
0
|
0
|
my $type_constraint = shift; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
( Maybe[$type_constraint] )->assert_return(@_) |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub returns_self { |
48
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
0
|
return $self if $self eq $_[0]; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
die "Expected to return '\$self' [$self], got [$_[0]]\n"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub returns_maybe_self { |
58
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
0
|
return unless defined $_[0]; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
return $self if $self eq $_[0]; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
die "Expected to return '\$self' [$self], got [$_[0]]\n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub returns_object_does_interface { |
70
|
0
|
|
|
0
|
0
|
0
|
my $interface = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
( ObjectDoesInterface[$interface] )->assert_return(@_) |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub returns_maybe_object_does_interface { |
78
|
0
|
|
|
0
|
0
|
0
|
my $interface = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
0
|
return unless defined $_[0]; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
( ObjectDoesInterface[$interface] )->assert_return(@_) |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub import { |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# TODO: We should only import what we really want to and select |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# see Function::Parameters on 'Wrapping Function::Parameters': |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
# Due to its nature as a lexical pragma, importing from Function::Parameters |
94
|
|
|
|
|
|
|
# always affects the scope that is currently being compiled. If you want to |
95
|
|
|
|
|
|
|
# write a wrapper module that enables Function::Parameters automatically, |
96
|
|
|
|
|
|
|
# just call Function::Parameters->import from your own import method (and |
97
|
|
|
|
|
|
|
# Function::Parameters->unimport from your unimport, as required). |
98
|
|
|
|
|
|
|
# |
99
|
1
|
|
|
1
|
|
25
|
Function::Parameters->import( |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
parameters => { |
102
|
|
|
|
|
|
|
shift => ['$orig', '$self'], |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
{ |
106
|
|
|
|
|
|
|
instance_method => { |
107
|
|
|
|
|
|
|
shift => ['$original', ['$instance', Object] ], |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
{ |
111
|
|
|
|
|
|
|
class_method => { |
112
|
|
|
|
|
|
|
shift => ['$original', ['$class', ClassName] ], |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
}, |
115
|
|
|
|
|
|
|
{ |
116
|
|
|
|
|
|
|
method_parameters => { |
117
|
|
|
|
|
|
|
shift => ['$original', ['$invocant', Invocant] ], |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
}, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
3931
|
Role::Tiny->import::into(scalar caller); |
123
|
|
|
|
|
|
|
# |
124
|
|
|
|
|
|
|
# provides `requires`, `with` |
125
|
|
|
|
|
|
|
# and the methodmodifiers `around`, `before`, and `after` |
126
|
|
|
|
|
|
|
|
127
|
1
|
|
|
|
|
6285
|
__PACKAGE__->export_to_level( 1, @_ ); |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
# whatever is in the list and can be exported, listed in `@EXPORT_OK` |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|