line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Deck; |
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
276
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $USES_MITE = "Mite::Class"; |
8
|
|
|
|
|
|
|
our $MITE_SHIM = "Acme::Mitey::Cards::Mite"; |
9
|
|
|
|
|
|
|
our $MITE_VERSION = "0.007003"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
2
|
|
|
2
|
|
11
|
require Scalar::Util; |
13
|
2
|
|
|
|
|
7
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
14
|
2
|
|
|
|
|
4
|
*blessed = \&Scalar::Util::blessed; |
15
|
2
|
|
|
|
|
3
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
16
|
2
|
|
|
|
|
4
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
17
|
2
|
|
|
|
|
2
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
18
|
2
|
|
|
|
|
4
|
*false = \&Acme::Mitey::Cards::Mite::false; |
19
|
2
|
|
|
|
|
3
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
20
|
2
|
|
|
|
|
5
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
21
|
2
|
|
|
|
|
3
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
22
|
2
|
|
|
|
|
3
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
23
|
2
|
|
|
|
|
10
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
24
|
2
|
|
|
|
|
71
|
*true = \&Acme::Mitey::Cards::Mite::true; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
2
|
|
|
2
|
|
472
|
require Acme::Mitey::Cards::Set; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
11
|
use mro 'c3'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
31
|
2
|
|
|
|
|
3
|
our @ISA; |
32
|
2
|
|
|
|
|
298
|
push @ISA, "Acme::Mitey::Cards::Set"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
1
|
50
|
|
1
|
0
|
908
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
37
|
1
|
|
33
|
|
|
9
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
38
|
1
|
|
|
|
|
3
|
my $self = bless {}, $class; |
39
|
|
|
|
|
|
|
my $args = |
40
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
41
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
42
|
1
|
50
|
|
|
|
5
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
43
|
1
|
|
|
|
|
2
|
my $no_build = delete $args->{__no_BUILD__}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Attribute: cards |
46
|
1
|
50
|
|
|
|
4
|
if ( exists $args->{"cards"} ) { |
47
|
|
|
|
|
|
|
( |
48
|
|
|
|
|
|
|
do { |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
51
|
0
|
|
|
|
|
0
|
ref( $args->{"cards"} ) eq 'ARRAY'; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
0
|
0
|
|
|
0
|
and do { |
54
|
0
|
|
|
|
|
0
|
my $ok = 1; |
55
|
0
|
|
|
|
|
0
|
for my $i ( @{ $args->{"cards"} } ) { |
|
0
|
|
|
|
|
0
|
|
56
|
|
|
|
|
|
|
( $ok = 0, last ) |
57
|
|
|
|
|
|
|
unless ( |
58
|
0
|
0
|
|
|
|
0
|
do { |
59
|
2
|
|
|
2
|
|
12
|
use Scalar::Util (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
323
|
|
60
|
0
|
0
|
|
|
|
0
|
Scalar::Util::blessed($i) |
61
|
|
|
|
|
|
|
and $i->isa(q[Acme::Mitey::Cards::Card]); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
}; |
65
|
0
|
|
|
|
|
0
|
$ok; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
) |
68
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
69
|
|
|
|
|
|
|
"cards", "CardArray"; |
70
|
0
|
|
|
|
|
0
|
$self->{"cards"} = $args->{"cards"}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Attribute: reverse |
74
|
1
|
|
|
|
|
2
|
do { |
75
|
|
|
|
|
|
|
my $value = |
76
|
1
|
50
|
|
|
|
13
|
exists( $args->{"reverse"} ) ? $args->{"reverse"} : "plain"; |
77
|
|
|
|
|
|
|
( |
78
|
|
|
|
|
|
|
( |
79
|
1
|
50
|
33
|
|
|
2
|
do { |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
82
|
1
|
50
|
|
|
|
3
|
defined($value) and do { |
83
|
1
|
50
|
|
|
|
8
|
ref( \$value ) eq 'SCALAR' |
84
|
|
|
|
|
|
|
or ref( \( my $val = $value ) ) eq 'SCALAR'; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
) |
88
|
|
|
|
|
|
|
&& ( length($value) > 0 ) |
89
|
|
|
|
|
|
|
) |
90
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
91
|
|
|
|
|
|
|
"reverse", "NonEmptyStr"; |
92
|
1
|
|
|
|
|
5
|
$self->{"reverse"} = $value; |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Attribute: original_cards |
96
|
1
|
50
|
|
|
|
3
|
if ( exists $args->{"original_cards"} ) { |
97
|
|
|
|
|
|
|
( |
98
|
|
|
|
|
|
|
do { |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
101
|
0
|
|
|
|
|
0
|
ref( $args->{"original_cards"} ) eq 'ARRAY'; |
102
|
|
|
|
|
|
|
} |
103
|
0
|
0
|
0
|
|
|
0
|
and do { |
104
|
0
|
|
|
|
|
0
|
my $ok = 1; |
105
|
0
|
|
|
|
|
0
|
for my $i ( @{ $args->{"original_cards"} } ) { |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
( $ok = 0, last ) |
107
|
|
|
|
|
|
|
unless ( |
108
|
0
|
0
|
|
|
|
0
|
do { |
109
|
2
|
|
|
2
|
|
12
|
use Scalar::Util (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
756
|
|
110
|
0
|
0
|
|
|
|
0
|
Scalar::Util::blessed($i) |
111
|
|
|
|
|
|
|
and $i->isa(q[Acme::Mitey::Cards::Card]); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
}; |
115
|
0
|
|
|
|
|
0
|
$ok; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
) |
118
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
119
|
|
|
|
|
|
|
"original_cards", "CardArray"; |
120
|
0
|
|
|
|
|
0
|
$self->{"original_cards"} = $args->{"original_cards"}; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Enforce strict constructor |
124
|
|
|
|
|
|
|
my @unknown = grep not(/\A(?:cards|original_cards|reverse)\z/), |
125
|
1
|
|
|
|
|
1
|
keys %{$args}; |
|
1
|
|
|
|
|
2
|
|
126
|
|
|
|
|
|
|
@unknown |
127
|
1
|
50
|
|
|
|
3
|
and croak( |
128
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Call BUILD methods |
131
|
1
|
50
|
33
|
|
|
4
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
1
|
50
|
|
|
|
15
|
|
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
6
|
return $self; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub DOES { |
137
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $role ) = @_; |
138
|
0
|
|
|
|
|
0
|
our %DOES; |
139
|
0
|
0
|
|
|
|
0
|
return $DOES{$role} if exists $DOES{$role}; |
140
|
0
|
0
|
|
|
|
0
|
return 1 if $role eq __PACKAGE__; |
141
|
0
|
|
|
|
|
0
|
return $self->SUPER::DOES($role); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub does { |
145
|
0
|
|
|
0
|
0
|
0
|
shift->DOES(@_); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
my $__XS = !$ENV{MITE_PURE_PERL} |
149
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# Accessors for original_cards |
152
|
|
|
|
|
|
|
sub original_cards { |
153
|
|
|
|
|
|
|
@_ > 1 |
154
|
0
|
|
|
|
|
0
|
? croak("original_cards is a read-only attribute of @{[ref $_[0]]}") |
155
|
|
|
|
|
|
|
: ( |
156
|
|
|
|
|
|
|
exists( $_[0]{"original_cards"} ) ? $_[0]{"original_cards"} : ( |
157
|
1
|
50
|
|
1
|
0
|
4
|
$_[0]{"original_cards"} = do { |
|
|
50
|
|
|
|
|
|
158
|
1
|
|
|
|
|
2
|
my $default_value = $_[0]->_build_original_cards; |
159
|
1
|
50
|
|
|
|
2
|
do { |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
162
|
1
|
50
|
|
|
|
4
|
( ref($default_value) eq 'ARRAY' ) and do { |
163
|
1
|
|
|
|
|
2
|
my $ok = 1; |
164
|
1
|
|
|
|
|
2
|
for my $i ( @{$default_value} ) { |
|
1
|
|
|
|
|
2
|
|
165
|
|
|
|
|
|
|
( $ok = 0, last ) |
166
|
|
|
|
|
|
|
unless ( |
167
|
54
|
50
|
|
|
|
61
|
do { |
168
|
2
|
|
|
2
|
|
14
|
use Scalar::Util (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
854
|
|
169
|
54
|
50
|
|
|
|
179
|
Scalar::Util::blessed($i) |
170
|
|
|
|
|
|
|
and |
171
|
|
|
|
|
|
|
$i->isa(q[Acme::Mitey::Cards::Card]); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
}; |
175
|
1
|
|
|
|
|
3
|
$ok; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
or croak( "Type check failed in default: %s should be %s", |
179
|
|
|
|
|
|
|
"original_cards", "CardArray" ); |
180
|
1
|
|
|
|
|
14
|
$default_value; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
) |
183
|
|
|
|
|
|
|
); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# Accessors for reverse |
187
|
|
|
|
|
|
|
if ($__XS) { |
188
|
|
|
|
|
|
|
Class::XSAccessor->import( |
189
|
|
|
|
|
|
|
chained => 1, |
190
|
|
|
|
|
|
|
"getters" => { "reverse" => "reverse" }, |
191
|
|
|
|
|
|
|
); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
else { |
194
|
|
|
|
|
|
|
*reverse = sub { |
195
|
|
|
|
|
|
|
@_ > 1 |
196
|
|
|
|
|
|
|
? croak("reverse is a read-only attribute of @{[ref $_[0]]}") |
197
|
|
|
|
|
|
|
: $_[0]{"reverse"}; |
198
|
|
|
|
|
|
|
}; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$SIGNATURE_FOR{"deal_hand"} = sub { |
204
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
my ( %out, %in, %tmp, $tmp, $dtmp, @head ); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
@_ == 2 && ( ref( $_[1] ) eq 'HASH' ) |
209
|
|
|
|
|
|
|
or @_ % 2 == 1 && @_ >= 1 |
210
|
|
|
|
|
|
|
or croak( |
211
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
212
|
|
|
|
|
|
|
"deal_hand", "that does not seem right", |
213
|
|
|
|
|
|
|
scalar(@_) |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
219
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
220
|
|
|
|
|
|
|
or croak( |
221
|
|
|
|
|
|
|
"Type check failed in signature for deal_hand: %s should be %s", |
222
|
|
|
|
|
|
|
"\$_[0]", "Defined" ); |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
%in = ( @_ == 1 and ( ref( $_[0] ) eq 'HASH' ) ) ? %{ $_[0] } : @_; |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# Parameter count (type: Int) |
227
|
|
|
|
|
|
|
$dtmp = exists( $in{"count"} ) ? $in{"count"} : "7"; |
228
|
|
|
|
|
|
|
( |
229
|
|
|
|
|
|
|
do { |
230
|
|
|
|
|
|
|
my $tmp = $dtmp; |
231
|
|
|
|
|
|
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
) |
234
|
|
|
|
|
|
|
or croak( |
235
|
|
|
|
|
|
|
"Type check failed in signature for deal_hand: %s should be %s", |
236
|
|
|
|
|
|
|
"\$_{\"count\"}", "Int" ); |
237
|
|
|
|
|
|
|
$out{"count"} = $dtmp; |
238
|
|
|
|
|
|
|
delete( $in{"count"} ); |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
my $SLURPY = \%in; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# Parameter args_for_hand (type: Slurpy[HashRef]) |
243
|
|
|
|
|
|
|
( ( ref($SLURPY) eq 'HASH' ) ) |
244
|
|
|
|
|
|
|
or croak( |
245
|
|
|
|
|
|
|
"Type check failed in signature for deal_hand: %s should be %s", |
246
|
|
|
|
|
|
|
"\$SLURPY", "Slurpy[HashRef]" ); |
247
|
|
|
|
|
|
|
$out{"args_for_hand"} = $SLURPY; |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
return ( |
250
|
|
|
|
|
|
|
&$__NEXT__( |
251
|
|
|
|
|
|
|
@head, |
252
|
|
|
|
|
|
|
bless( |
253
|
|
|
|
|
|
|
\%out, |
254
|
|
|
|
|
|
|
"Acme::Mitey::Cards::Deck::__NAMED_ARGUMENTS__::deal_hand" |
255
|
|
|
|
|
|
|
) |
256
|
|
|
|
|
|
|
) |
257
|
|
|
|
|
|
|
); |
258
|
|
|
|
|
|
|
}; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
{ |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Deck::__NAMED_ARGUMENTS__::deal_hand; |
263
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
264
|
2
|
|
|
2
|
|
9
|
no warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
408
|
|
265
|
2
|
|
|
2
|
|
5
|
sub args_for_hand { $_[0]{"args_for_hand"} } |
266
|
4
|
|
|
4
|
|
98
|
sub count { $_[0]{"count"} } |
267
|
0
|
|
|
0
|
|
|
sub has_count { exists $_[0]{"count"} } |
268
|
|
|
|
|
|
|
1; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$SIGNATURE_FOR{"discard_jokers"} = sub { |
272
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
@_ == 1 |
277
|
|
|
|
|
|
|
or croak( |
278
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
279
|
|
|
|
|
|
|
"discard_jokers", "expected exactly 1 parameters", |
280
|
|
|
|
|
|
|
scalar(@_) |
281
|
|
|
|
|
|
|
); |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
286
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
287
|
|
|
|
|
|
|
or croak( |
288
|
|
|
|
|
|
|
"Type check failed in signature for discard_jokers: %s should be %s", |
289
|
|
|
|
|
|
|
"\$_[0]", "Defined" |
290
|
|
|
|
|
|
|
); |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
293
|
|
|
|
|
|
|
}; |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
1; |
296
|
|
|
|
|
|
|
} |