line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Card::Numeric; |
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
76
|
|
5
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
68
|
|
6
|
3
|
|
|
3
|
|
13
|
no warnings qw( once void ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
298
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
9
|
|
|
|
|
|
|
our $MITE_SHIM = "Acme::Mitey::Cards::Mite"; |
10
|
|
|
|
|
|
|
our $MITE_VERSION = "0.010002"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Mite keywords |
13
|
|
|
|
|
|
|
BEGIN { |
14
|
3
|
|
|
3
|
|
12
|
my ( $SHIM, $CALLER ) = |
15
|
|
|
|
|
|
|
( "Acme::Mitey::Cards::Mite", "Acme::Mitey::Cards::Card::Numeric" ); |
16
|
|
|
|
|
|
|
( |
17
|
|
|
|
|
|
|
*after, *around, *before, *extends, *field, |
18
|
|
|
|
|
|
|
*has, *param, *signature_for, *with |
19
|
|
|
|
|
|
|
) |
20
|
3
|
|
|
|
|
4
|
= do { |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
23
|
3
|
|
|
3
|
|
17
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
557
|
|
24
|
|
|
|
|
|
|
( |
25
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_after( $CALLER, "class", @_ ) }, |
26
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_around( $CALLER, "class", @_ ) }, |
27
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_before( $CALLER, "class", @_ ) }, |
28
|
|
|
|
3
|
|
|
sub { }, |
29
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, field => @_ ) }, |
30
|
6
|
|
|
6
|
|
22
|
sub { $SHIM->HANDLE_has( $CALLER, has => @_ ) }, |
31
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_has( $CALLER, param => @_ ) }, |
32
|
6
|
|
|
6
|
|
45
|
sub { $SHIM->HANDLE_signature_for( $CALLER, "class", @_ ) }, |
33
|
0
|
|
|
0
|
|
0
|
sub { $SHIM->HANDLE_with( $CALLER, @_ ) }, |
34
|
3
|
|
|
|
|
443
|
); |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Mite imports |
39
|
|
|
|
|
|
|
BEGIN { |
40
|
3
|
|
|
3
|
|
17
|
require Scalar::Util; |
41
|
3
|
|
|
|
|
8
|
*STRICT = \&Acme::Mitey::Cards::Mite::STRICT; |
42
|
3
|
|
|
|
|
6
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
43
|
3
|
|
|
|
|
6
|
*blessed = \&Scalar::Util::blessed; |
44
|
3
|
|
|
|
|
5
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
45
|
3
|
|
|
|
|
5
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
46
|
3
|
|
|
|
|
4
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
47
|
3
|
|
|
|
|
11
|
*false = \&Acme::Mitey::Cards::Mite::false; |
48
|
3
|
|
|
|
|
7
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
49
|
3
|
|
|
|
|
6
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
50
|
3
|
|
|
|
|
3
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
51
|
3
|
|
|
|
|
6
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
52
|
3
|
|
|
|
|
5
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
53
|
3
|
|
|
|
|
102
|
*true = \&Acme::Mitey::Cards::Mite::true; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
BEGIN { |
57
|
3
|
|
|
3
|
|
862
|
require Acme::Mitey::Cards::Card; |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
3
|
|
15
|
use mro 'c3'; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
15
|
|
60
|
3
|
|
|
|
|
14
|
our @ISA; |
61
|
3
|
|
|
|
|
727
|
push @ISA, "Acme::Mitey::Cards::Card"; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Standard Moose/Moo-style constructor |
65
|
|
|
|
|
|
|
sub new { |
66
|
42
|
50
|
|
42
|
0
|
160
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
67
|
42
|
|
66
|
|
|
91
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
68
|
42
|
|
|
|
|
63
|
my $self = bless {}, $class; |
69
|
|
|
|
|
|
|
my $args = |
70
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
71
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
72
|
42
|
50
|
|
|
|
121
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
73
|
42
|
|
|
|
|
54
|
my $no_build = delete $args->{__no_BUILD__}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Attribute deck (type: Deck) |
76
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card.pm, line 9 |
77
|
42
|
100
|
|
|
|
71
|
if ( exists $args->{"deck"} ) { |
78
|
|
|
|
|
|
|
blessed( $args->{"deck"} ) |
79
|
40
|
50
|
33
|
|
|
176
|
&& $args->{"deck"}->isa("Acme::Mitey::Cards::Deck") |
80
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
81
|
|
|
|
|
|
|
"deck", "Deck"; |
82
|
40
|
|
|
|
|
80
|
$self->{"deck"} = $args->{"deck"}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
require Scalar::Util && Scalar::Util::weaken( $self->{"deck"} ) |
85
|
42
|
100
|
33
|
|
|
217
|
if ref $self->{"deck"}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Attribute reverse (type: Str) |
88
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card.pm, line 19 |
89
|
42
|
100
|
|
|
|
71
|
if ( exists $args->{"reverse"} ) { |
90
|
2
|
50
|
|
|
|
3
|
do { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
93
|
2
|
50
|
|
|
|
4
|
defined( $args->{"reverse"} ) and do { |
94
|
|
|
|
|
|
|
ref( \$args->{"reverse"} ) eq 'SCALAR' |
95
|
2
|
50
|
|
|
|
9
|
or ref( \( my $val = $args->{"reverse"} ) ) eq 'SCALAR'; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
99
|
|
|
|
|
|
|
"reverse", "Str"; |
100
|
2
|
|
|
|
|
5
|
$self->{"reverse"} = $args->{"reverse"}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Attribute suit (type: Suit) |
104
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Numeric.pm, line 13 |
105
|
42
|
50
|
|
|
|
64
|
croak "Missing key in constructor: suit" unless exists $args->{"suit"}; |
106
|
42
|
|
|
|
|
50
|
do { |
107
|
42
|
|
|
|
|
59
|
my $coerced_value = do { |
108
|
42
|
|
|
|
|
54
|
my $to_coerce = $args->{"suit"}; |
109
|
|
|
|
|
|
|
( |
110
|
|
|
|
|
|
|
( |
111
|
|
|
|
|
|
|
do { |
112
|
3
|
|
|
3
|
|
19
|
use Scalar::Util (); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
2406
|
|
113
|
42
|
50
|
|
|
|
183
|
Scalar::Util::blessed($to_coerce) |
114
|
|
|
|
|
|
|
and $to_coerce->isa(q[Acme::Mitey::Cards::Suit]); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
) |
117
|
|
|
|
|
|
|
) ? $to_coerce : ( |
118
|
|
|
|
|
|
|
do { |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
121
|
0
|
0
|
|
|
|
0
|
defined($to_coerce) and do { |
122
|
0
|
0
|
|
|
|
0
|
ref( \$to_coerce ) eq 'SCALAR' |
123
|
|
|
|
|
|
|
or ref( \( my $val = $to_coerce ) ) eq 'SCALAR'; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
) |
127
|
|
|
|
|
|
|
? scalar( |
128
|
42
|
0
|
|
|
|
47
|
do { |
|
|
50
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
local $_ = $to_coerce; |
130
|
0
|
|
|
|
|
0
|
do { |
131
|
0
|
|
|
|
|
0
|
my $method = lc($_); |
132
|
0
|
|
|
|
|
0
|
'Acme::Mitey::Cards::Suit'->$method; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
) |
136
|
|
|
|
|
|
|
: $to_coerce; |
137
|
|
|
|
|
|
|
}; |
138
|
42
|
50
|
33
|
|
|
153
|
blessed($coerced_value) |
139
|
|
|
|
|
|
|
&& $coerced_value->isa("Acme::Mitey::Cards::Suit") |
140
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
141
|
|
|
|
|
|
|
"suit", "Suit"; |
142
|
42
|
|
|
|
|
87
|
$self->{"suit"} = $coerced_value; |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Attribute number (type: CardNumber) |
146
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Numeric.pm, line 20 |
147
|
|
|
|
|
|
|
croak "Missing key in constructor: number" |
148
|
42
|
50
|
|
|
|
73
|
unless exists $args->{"number"}; |
149
|
42
|
|
|
|
|
53
|
do { |
150
|
42
|
|
|
|
|
44
|
my $coerced_value = do { |
151
|
42
|
|
|
|
|
53
|
my $to_coerce = $args->{"number"}; |
152
|
|
|
|
|
|
|
( |
153
|
|
|
|
|
|
|
( |
154
|
|
|
|
|
|
|
do { |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
157
|
|
|
|
|
|
|
( |
158
|
|
|
|
|
|
|
do { |
159
|
|
|
|
|
|
|
my $tmp = $to_coerce; |
160
|
|
|
|
|
|
|
defined($tmp) |
161
|
|
|
|
|
|
|
and !ref($tmp) |
162
|
|
|
|
|
|
|
and $tmp =~ /\A-?[0-9]+\z/; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
&& ( $to_coerce >= 1 ) |
167
|
|
|
|
|
|
|
&& ( $to_coerce <= 10 ) |
168
|
|
|
|
|
|
|
) |
169
|
|
|
|
|
|
|
) ? $to_coerce : ( |
170
|
|
|
|
|
|
|
do { |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
173
|
0
|
0
|
0
|
|
|
0
|
( defined($to_coerce) |
174
|
|
|
|
|
|
|
and !ref($to_coerce) |
175
|
|
|
|
|
|
|
and $to_coerce =~ m{\A(?:[Aa])\z} ); |
176
|
|
|
|
|
|
|
} |
177
|
42
|
0
|
33
|
|
|
48
|
) ? scalar( do { local $_ = $to_coerce; 1 } ) : $to_coerce; |
|
0
|
50
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
178
|
|
|
|
|
|
|
}; |
179
|
|
|
|
|
|
|
( |
180
|
42
|
50
|
33
|
|
|
59
|
do { |
|
|
|
33
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
183
|
|
|
|
|
|
|
( |
184
|
42
|
|
|
|
|
47
|
do { |
185
|
42
|
|
|
|
|
51
|
my $tmp = $coerced_value; |
186
|
42
|
50
|
33
|
|
|
262
|
defined($tmp) |
187
|
|
|
|
|
|
|
and !ref($tmp) |
188
|
|
|
|
|
|
|
and $tmp =~ /\A-?[0-9]+\z/; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
&& ( $coerced_value >= 1 ) |
193
|
|
|
|
|
|
|
&& ( $coerced_value <= 10 ) |
194
|
|
|
|
|
|
|
) |
195
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
196
|
|
|
|
|
|
|
"number", "CardNumber"; |
197
|
42
|
|
|
|
|
85
|
$self->{"number"} = $coerced_value; |
198
|
|
|
|
|
|
|
}; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# Call BUILD methods |
201
|
42
|
50
|
33
|
|
|
67
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
42
|
50
|
|
|
|
121
|
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# Unrecognized parameters |
204
|
|
|
|
|
|
|
my @unknown = grep not(/\A(?:deck|number|reverse|suit)\z/), |
205
|
42
|
|
|
|
|
50
|
keys %{$args}; |
|
42
|
|
|
|
|
216
|
|
206
|
|
|
|
|
|
|
@unknown |
207
|
42
|
50
|
|
|
|
89
|
and croak( |
208
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
209
|
|
|
|
|
|
|
|
210
|
42
|
|
|
|
|
149
|
return $self; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
my $__XS = !$ENV{MITE_PURE_PERL} |
214
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# Accessors for number |
217
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Numeric.pm, line 20 |
218
|
|
|
|
|
|
|
if ($__XS) { |
219
|
|
|
|
|
|
|
Class::XSAccessor->import( |
220
|
|
|
|
|
|
|
chained => 1, |
221
|
|
|
|
|
|
|
"getters" => { "number" => "number" }, |
222
|
|
|
|
|
|
|
); |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
else { |
225
|
|
|
|
|
|
|
*number = sub { |
226
|
|
|
|
|
|
|
@_ == 1 or croak('Reader "number" usage: $self->number()'); |
227
|
|
|
|
|
|
|
$_[0]{"number"}; |
228
|
|
|
|
|
|
|
}; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Accessors for suit |
232
|
|
|
|
|
|
|
# has declaration, file lib/Acme/Mitey/Cards/Card/Numeric.pm, line 13 |
233
|
|
|
|
|
|
|
if ($__XS) { |
234
|
|
|
|
|
|
|
Class::XSAccessor->import( |
235
|
|
|
|
|
|
|
chained => 1, |
236
|
|
|
|
|
|
|
"getters" => { "suit" => "suit" }, |
237
|
|
|
|
|
|
|
); |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
else { |
240
|
|
|
|
|
|
|
*suit = sub { |
241
|
|
|
|
|
|
|
@_ == 1 or croak('Reader "suit" usage: $self->suit()'); |
242
|
|
|
|
|
|
|
$_[0]{"suit"}; |
243
|
|
|
|
|
|
|
}; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# See UNIVERSAL |
247
|
|
|
|
|
|
|
sub DOES { |
248
|
0
|
|
|
0
|
0
|
|
my ( $self, $role ) = @_; |
249
|
0
|
|
|
|
|
|
our %DOES; |
250
|
0
|
0
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
251
|
0
|
0
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
252
|
0
|
|
|
|
|
|
return $self->SUPER::DOES($role); |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# Alias for Moose/Moo-compatibility |
256
|
|
|
|
|
|
|
sub does { |
257
|
0
|
|
|
0
|
0
|
|
shift->DOES(@_); |
258
|
|
|
|
|
|
|
} |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Method signatures |
261
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
$SIGNATURE_FOR{"number_or_a"} = sub { |
264
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
@_ == 1 |
269
|
|
|
|
|
|
|
or |
270
|
|
|
|
|
|
|
croak( "Wrong number of parameters in signature for %s: got %d, %s", |
271
|
|
|
|
|
|
|
"number_or_a", scalar(@_), "expected exactly 1 parameters" ); |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
# Parameter invocant (type: Defined) |
276
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
277
|
|
|
|
|
|
|
or croak( |
278
|
|
|
|
|
|
|
"Type check failed in signature for number_or_a: %s should be %s", |
279
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
282
|
|
|
|
|
|
|
}; |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$SIGNATURE_FOR{"to_string"} = |
285
|
|
|
|
|
|
|
$Acme::Mitey::Cards::Card::SIGNATURE_FOR{"to_string"}; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
1; |
288
|
|
|
|
|
|
|
} |