line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
{ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Card::Face; |
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
72
|
|
5
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
455
|
|
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
|
3
|
|
|
3
|
|
19
|
require Scalar::Util; |
13
|
3
|
|
|
|
|
9
|
*bare = \&Acme::Mitey::Cards::Mite::bare; |
14
|
3
|
|
|
|
|
18
|
*blessed = \&Scalar::Util::blessed; |
15
|
3
|
|
|
|
|
6
|
*carp = \&Acme::Mitey::Cards::Mite::carp; |
16
|
3
|
|
|
|
|
4
|
*confess = \&Acme::Mitey::Cards::Mite::confess; |
17
|
3
|
|
|
|
|
6
|
*croak = \&Acme::Mitey::Cards::Mite::croak; |
18
|
3
|
|
|
|
|
4
|
*false = \&Acme::Mitey::Cards::Mite::false; |
19
|
3
|
|
|
|
|
6
|
*guard = \&Acme::Mitey::Cards::Mite::guard; |
20
|
3
|
|
|
|
|
5
|
*lazy = \&Acme::Mitey::Cards::Mite::lazy; |
21
|
3
|
|
|
|
|
4
|
*ro = \&Acme::Mitey::Cards::Mite::ro; |
22
|
3
|
|
|
|
|
5
|
*rw = \&Acme::Mitey::Cards::Mite::rw; |
23
|
3
|
|
|
|
|
18
|
*rwp = \&Acme::Mitey::Cards::Mite::rwp; |
24
|
3
|
|
|
|
|
105
|
*true = \&Acme::Mitey::Cards::Mite::true; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
3
|
|
|
3
|
|
495
|
require Acme::Mitey::Cards::Card; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
|
16
|
use mro 'c3'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
14
|
|
31
|
3
|
|
|
|
|
12
|
our @ISA; |
32
|
3
|
|
|
|
|
332
|
push @ISA, "Acme::Mitey::Cards::Card"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
15
|
50
|
|
15
|
0
|
107
|
my $class = ref( $_[0] ) ? ref(shift) : shift; |
37
|
15
|
|
66
|
|
|
43
|
my $meta = ( $Mite::META{$class} ||= $class->__META__ ); |
38
|
15
|
|
|
|
|
24
|
my $self = bless {}, $class; |
39
|
|
|
|
|
|
|
my $args = |
40
|
|
|
|
|
|
|
$meta->{HAS_BUILDARGS} |
41
|
|
|
|
|
|
|
? $class->BUILDARGS(@_) |
42
|
15
|
50
|
|
|
|
51
|
: { ( @_ == 1 ) ? %{ $_[0] } : @_ }; |
|
0
|
50
|
|
|
|
0
|
|
43
|
15
|
|
|
|
|
19
|
my $no_build = delete $args->{__no_BUILD__}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Attribute: deck |
46
|
15
|
100
|
|
|
|
26
|
if ( exists $args->{"deck"} ) { |
47
|
|
|
|
|
|
|
( |
48
|
12
|
50
|
|
|
|
14
|
do { |
49
|
3
|
|
|
3
|
|
20
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
493
|
|
50
|
|
|
|
|
|
|
Scalar::Util::blessed( $args->{"deck"} ) |
51
|
12
|
50
|
|
|
|
66
|
and $args->{"deck"}->isa(q[Acme::Mitey::Cards::Deck]); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
) |
54
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
55
|
|
|
|
|
|
|
"deck", "Deck"; |
56
|
12
|
|
|
|
|
27
|
$self->{"deck"} = $args->{"deck"}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
require Scalar::Util && Scalar::Util::weaken( $self->{"deck"} ) |
59
|
15
|
100
|
33
|
|
|
92
|
if exists $self->{"deck"}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Attribute: reverse |
62
|
15
|
100
|
|
|
|
24
|
if ( exists $args->{"reverse"} ) { |
63
|
1
|
50
|
|
|
|
1
|
do { |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
66
|
1
|
50
|
|
|
|
3
|
defined( $args->{"reverse"} ) and do { |
67
|
|
|
|
|
|
|
ref( \$args->{"reverse"} ) eq 'SCALAR' |
68
|
1
|
50
|
|
|
|
18
|
or ref( \( my $val = $args->{"reverse"} ) ) eq 'SCALAR'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
72
|
|
|
|
|
|
|
"reverse", "Str"; |
73
|
1
|
|
|
|
|
4
|
$self->{"reverse"} = $args->{"reverse"}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Attribute: suit |
77
|
15
|
50
|
|
|
|
27
|
croak "Missing key in constructor: suit" unless exists $args->{"suit"}; |
78
|
15
|
|
|
|
|
18
|
do { |
79
|
15
|
|
|
|
|
17
|
my $coerced_value = do { |
80
|
15
|
|
|
|
|
19
|
my $to_coerce = $args->{"suit"}; |
81
|
|
|
|
|
|
|
( |
82
|
|
|
|
|
|
|
( |
83
|
|
|
|
|
|
|
do { |
84
|
3
|
|
|
3
|
|
18
|
use Scalar::Util (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
249
|
|
85
|
15
|
100
|
|
|
|
84
|
Scalar::Util::blessed($to_coerce) |
86
|
|
|
|
|
|
|
and $to_coerce->isa(q[Acme::Mitey::Cards::Suit]); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
) |
89
|
|
|
|
|
|
|
) ? $to_coerce : ( |
90
|
|
|
|
|
|
|
do { |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
93
|
1
|
50
|
|
|
|
4
|
defined($to_coerce) and do { |
94
|
1
|
50
|
|
|
|
5
|
ref( \$to_coerce ) eq 'SCALAR' |
95
|
|
|
|
|
|
|
or ref( \( my $val = $to_coerce ) ) eq 'SCALAR'; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
) |
99
|
|
|
|
|
|
|
? scalar( |
100
|
15
|
50
|
|
|
|
16
|
do { |
|
|
100
|
|
|
|
|
|
101
|
1
|
|
|
|
|
1
|
local $_ = $to_coerce; |
102
|
1
|
|
|
|
|
1
|
do { |
103
|
1
|
|
|
|
|
2
|
my $method = lc($_); |
104
|
1
|
|
|
|
|
25
|
'Acme::Mitey::Cards::Suit'->$method; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
) |
108
|
|
|
|
|
|
|
: $to_coerce; |
109
|
|
|
|
|
|
|
}; |
110
|
|
|
|
|
|
|
( |
111
|
15
|
50
|
|
|
|
21
|
do { |
112
|
3
|
|
|
3
|
|
16
|
use Scalar::Util (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1958
|
|
113
|
15
|
50
|
|
|
|
74
|
Scalar::Util::blessed($coerced_value) |
114
|
|
|
|
|
|
|
and $coerced_value->isa(q[Acme::Mitey::Cards::Suit]); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
) |
117
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", |
118
|
|
|
|
|
|
|
"suit", "Suit"; |
119
|
15
|
|
|
|
|
28
|
$self->{"suit"} = $coerced_value; |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Attribute: face |
123
|
15
|
50
|
|
|
|
38
|
croak "Missing key in constructor: face" unless exists $args->{"face"}; |
124
|
15
|
100
|
|
|
|
20
|
do { |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Mite; |
127
|
|
|
|
|
|
|
( defined( $args->{"face"} ) |
128
|
|
|
|
|
|
|
and !ref( $args->{"face"} ) |
129
|
15
|
50
|
33
|
|
|
86
|
and $args->{"face"} =~ m{\A(?:(?:Jack|King|Queen))\z} ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
or croak "Type check failed in constructor: %s should be %s", "face", |
132
|
|
|
|
|
|
|
"Character"; |
133
|
14
|
|
|
|
|
24
|
$self->{"face"} = $args->{"face"}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# Enforce strict constructor |
136
|
14
|
|
|
|
|
17
|
my @unknown = grep not(/\A(?:deck|face|reverse|suit)\z/), keys %{$args}; |
|
14
|
|
|
|
|
57
|
|
137
|
|
|
|
|
|
|
@unknown |
138
|
14
|
50
|
|
|
|
38
|
and croak( |
139
|
|
|
|
|
|
|
"Unexpected keys in constructor: " . join( q[, ], sort @unknown ) ); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Call BUILD methods |
142
|
14
|
50
|
33
|
|
|
25
|
$self->BUILDALL($args) if ( !$no_build and @{ $meta->{BUILD} || [] } ); |
|
14
|
50
|
|
|
|
46
|
|
143
|
|
|
|
|
|
|
|
144
|
14
|
|
|
|
|
45
|
return $self; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub DOES { |
148
|
0
|
|
|
0
|
0
|
|
my ( $self, $role ) = @_; |
149
|
0
|
|
|
|
|
|
our %DOES; |
150
|
0
|
0
|
|
|
|
|
return $DOES{$role} if exists $DOES{$role}; |
151
|
0
|
0
|
|
|
|
|
return 1 if $role eq __PACKAGE__; |
152
|
0
|
|
|
|
|
|
return $self->SUPER::DOES($role); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub does { |
156
|
0
|
|
|
0
|
0
|
|
shift->DOES(@_); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $__XS = !$ENV{MITE_PURE_PERL} |
160
|
|
|
|
|
|
|
&& eval { require Class::XSAccessor; Class::XSAccessor->VERSION("1.19") }; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# Accessors for face |
163
|
|
|
|
|
|
|
if ($__XS) { |
164
|
|
|
|
|
|
|
Class::XSAccessor->import( |
165
|
|
|
|
|
|
|
chained => 1, |
166
|
|
|
|
|
|
|
"getters" => { "face" => "face" }, |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
else { |
170
|
|
|
|
|
|
|
*face = sub { |
171
|
|
|
|
|
|
|
@_ > 1 |
172
|
|
|
|
|
|
|
? croak("face is a read-only attribute of @{[ref $_[0]]}") |
173
|
|
|
|
|
|
|
: $_[0]{"face"}; |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Accessors for suit |
178
|
|
|
|
|
|
|
if ($__XS) { |
179
|
|
|
|
|
|
|
Class::XSAccessor->import( |
180
|
|
|
|
|
|
|
chained => 1, |
181
|
|
|
|
|
|
|
"getters" => { "suit" => "suit" }, |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
else { |
185
|
|
|
|
|
|
|
*suit = sub { |
186
|
|
|
|
|
|
|
@_ > 1 |
187
|
|
|
|
|
|
|
? croak("suit is a read-only attribute of @{[ref $_[0]]}") |
188
|
|
|
|
|
|
|
: $_[0]{"suit"}; |
189
|
|
|
|
|
|
|
}; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
our %SIGNATURE_FOR; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
$SIGNATURE_FOR{"face_abbreviation"} = sub { |
195
|
|
|
|
|
|
|
my $__NEXT__ = shift; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
my ( %tmp, $tmp, @head ); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
@_ == 1 |
200
|
|
|
|
|
|
|
or croak( |
201
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: %s, got %d", |
202
|
|
|
|
|
|
|
"face_abbreviation", "expected exactly 1 parameters", |
203
|
|
|
|
|
|
|
scalar(@_) |
204
|
|
|
|
|
|
|
); |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
@head = splice( @_, 0, 1 ); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# Parameter $head[0] (type: Defined) |
209
|
|
|
|
|
|
|
( defined( $head[0] ) ) |
210
|
|
|
|
|
|
|
or croak( |
211
|
|
|
|
|
|
|
"Type check failed in signature for face_abbreviation: %s should be %s", |
212
|
|
|
|
|
|
|
"\$_[0]", "Defined" |
213
|
|
|
|
|
|
|
); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
return ( &$__NEXT__( @head, @_ ) ); |
216
|
|
|
|
|
|
|
}; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
$SIGNATURE_FOR{"to_string"} = |
219
|
|
|
|
|
|
|
$Acme::Mitey::Cards::Card::SIGNATURE_FOR{"to_string"}; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
1; |
222
|
|
|
|
|
|
|
} |