Merge lp:~percona-toolkit-dev/percona-toolkit/fix-1073532-Mo-Scalar-Util-PP into lp:percona-toolkit/2.1
- fix-1073532-Mo-Scalar-Util-PP
- Merge into 2.1
Proposed by
Brian Fraser
Status: | Merged |
---|---|
Approved by: | Daniel Nichter |
Approved revision: | 442 |
Merged at revision: | 447 |
Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/fix-1073532-Mo-Scalar-Util-PP |
Merge into: | lp:percona-toolkit/2.1 |
Diff against target: |
409 lines (+114/-61) 12 files modified
bin/pt-archiver (+7/-6) bin/pt-deadlock-logger (+7/-6) bin/pt-kill (+7/-6) bin/pt-online-schema-change (+7/-6) bin/pt-slave-delay (+7/-6) bin/pt-slave-find (+7/-6) bin/pt-slave-restart (+7/-6) bin/pt-table-checksum (+7/-6) bin/pt-variable-advisor (+7/-6) lib/Mo.pm (+7/-7) t/lib/Mo/isa.t (+16/-0) t/lib/Mo/isa_subtest.pm (+28/-0) |
To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-1073532-Mo-Scalar-Util-PP |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Nichter | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/pt-archiver' | |||
2 | --- bin/pt-archiver 2012-10-31 01:12:57 +0000 | |||
3 | +++ bin/pt-archiver 2012-10-31 15:31:23 +0000 | |||
4 | @@ -1104,14 +1104,15 @@ | |||
5 | 1104 | use warnings qw( FATAL all ); | 1104 | use warnings qw( FATAL all ); |
6 | 1105 | 1105 | ||
7 | 1106 | use Carp (); | 1106 | use Carp (); |
9 | 1107 | use Scalar::Util (); | 1107 | use Scalar::Util qw(looks_like_number blessed); |
10 | 1108 | |||
11 | 1108 | 1109 | ||
12 | 1109 | our %TYPES = ( | 1110 | our %TYPES = ( |
16 | 1110 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1111 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
17 | 1111 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1112 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
18 | 1112 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1113 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
19 | 1113 | Str => sub { defined $_[0] }, | 1114 | Str => sub { defined $_[0] }, |
21 | 1114 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1115 | Object => sub { defined $_[0] && blessed($_[0]) }, |
22 | 1115 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1116 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
23 | 1116 | 1117 | ||
24 | 1117 | map { | 1118 | map { |
25 | @@ -1285,7 +1286,7 @@ | |||
26 | 1285 | $method = sub { | 1286 | $method = sub { |
27 | 1286 | if ( $#_ ) { | 1287 | if ( $#_ ) { |
28 | 1287 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1288 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
30 | 1288 | unless blessed($_[1]) && $_[1]->does($role) | 1289 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
31 | 1289 | } | 1290 | } |
32 | 1290 | goto &$original_method | 1291 | goto &$original_method |
33 | 1291 | }; | 1292 | }; |
34 | 1292 | 1293 | ||
35 | === modified file 'bin/pt-deadlock-logger' | |||
36 | --- bin/pt-deadlock-logger 2012-10-31 09:18:34 +0000 | |||
37 | +++ bin/pt-deadlock-logger 2012-10-31 15:31:23 +0000 | |||
38 | @@ -1101,14 +1101,15 @@ | |||
39 | 1101 | use warnings qw( FATAL all ); | 1101 | use warnings qw( FATAL all ); |
40 | 1102 | 1102 | ||
41 | 1103 | use Carp (); | 1103 | use Carp (); |
43 | 1104 | use Scalar::Util (); | 1104 | use Scalar::Util qw(looks_like_number blessed); |
44 | 1105 | |||
45 | 1105 | 1106 | ||
46 | 1106 | our %TYPES = ( | 1107 | our %TYPES = ( |
50 | 1107 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1108 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
51 | 1108 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1109 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
52 | 1109 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1110 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
53 | 1110 | Str => sub { defined $_[0] }, | 1111 | Str => sub { defined $_[0] }, |
55 | 1111 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1112 | Object => sub { defined $_[0] && blessed($_[0]) }, |
56 | 1112 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1113 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
57 | 1113 | 1114 | ||
58 | 1114 | map { | 1115 | map { |
59 | @@ -1282,7 +1283,7 @@ | |||
60 | 1282 | $method = sub { | 1283 | $method = sub { |
61 | 1283 | if ( $#_ ) { | 1284 | if ( $#_ ) { |
62 | 1284 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1285 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
64 | 1285 | unless blessed($_[1]) && $_[1]->does($role) | 1286 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
65 | 1286 | } | 1287 | } |
66 | 1287 | goto &$original_method | 1288 | goto &$original_method |
67 | 1288 | }; | 1289 | }; |
68 | 1289 | 1290 | ||
69 | === modified file 'bin/pt-kill' | |||
70 | --- bin/pt-kill 2012-10-31 09:18:34 +0000 | |||
71 | +++ bin/pt-kill 2012-10-31 15:31:23 +0000 | |||
72 | @@ -1108,14 +1108,15 @@ | |||
73 | 1108 | use warnings qw( FATAL all ); | 1108 | use warnings qw( FATAL all ); |
74 | 1109 | 1109 | ||
75 | 1110 | use Carp (); | 1110 | use Carp (); |
77 | 1111 | use Scalar::Util (); | 1111 | use Scalar::Util qw(looks_like_number blessed); |
78 | 1112 | |||
79 | 1112 | 1113 | ||
80 | 1113 | our %TYPES = ( | 1114 | our %TYPES = ( |
84 | 1114 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1115 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
85 | 1115 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1116 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
86 | 1116 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1117 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
87 | 1117 | Str => sub { defined $_[0] }, | 1118 | Str => sub { defined $_[0] }, |
89 | 1118 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1119 | Object => sub { defined $_[0] && blessed($_[0]) }, |
90 | 1119 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1120 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
91 | 1120 | 1121 | ||
92 | 1121 | map { | 1122 | map { |
93 | @@ -1289,7 +1290,7 @@ | |||
94 | 1289 | $method = sub { | 1290 | $method = sub { |
95 | 1290 | if ( $#_ ) { | 1291 | if ( $#_ ) { |
96 | 1291 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1292 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
98 | 1292 | unless blessed($_[1]) && $_[1]->does($role) | 1293 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
99 | 1293 | } | 1294 | } |
100 | 1294 | goto &$original_method | 1295 | goto &$original_method |
101 | 1295 | }; | 1296 | }; |
102 | 1296 | 1297 | ||
103 | === modified file 'bin/pt-online-schema-change' | |||
104 | --- bin/pt-online-schema-change 2012-10-31 09:18:34 +0000 | |||
105 | +++ bin/pt-online-schema-change 2012-10-31 15:31:23 +0000 | |||
106 | @@ -1114,14 +1114,15 @@ | |||
107 | 1114 | use warnings qw( FATAL all ); | 1114 | use warnings qw( FATAL all ); |
108 | 1115 | 1115 | ||
109 | 1116 | use Carp (); | 1116 | use Carp (); |
111 | 1117 | use Scalar::Util (); | 1117 | use Scalar::Util qw(looks_like_number blessed); |
112 | 1118 | |||
113 | 1118 | 1119 | ||
114 | 1119 | our %TYPES = ( | 1120 | our %TYPES = ( |
118 | 1120 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1121 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
119 | 1121 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1122 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
120 | 1122 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1123 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
121 | 1123 | Str => sub { defined $_[0] }, | 1124 | Str => sub { defined $_[0] }, |
123 | 1124 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1125 | Object => sub { defined $_[0] && blessed($_[0]) }, |
124 | 1125 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1126 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
125 | 1126 | 1127 | ||
126 | 1127 | map { | 1128 | map { |
127 | @@ -1295,7 +1296,7 @@ | |||
128 | 1295 | $method = sub { | 1296 | $method = sub { |
129 | 1296 | if ( $#_ ) { | 1297 | if ( $#_ ) { |
130 | 1297 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1298 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
132 | 1298 | unless blessed($_[1]) && $_[1]->does($role) | 1299 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
133 | 1299 | } | 1300 | } |
134 | 1300 | goto &$original_method | 1301 | goto &$original_method |
135 | 1301 | }; | 1302 | }; |
136 | 1302 | 1303 | ||
137 | === modified file 'bin/pt-slave-delay' | |||
138 | --- bin/pt-slave-delay 2012-10-31 09:18:34 +0000 | |||
139 | +++ bin/pt-slave-delay 2012-10-31 15:31:23 +0000 | |||
140 | @@ -1101,14 +1101,15 @@ | |||
141 | 1101 | use warnings qw( FATAL all ); | 1101 | use warnings qw( FATAL all ); |
142 | 1102 | 1102 | ||
143 | 1103 | use Carp (); | 1103 | use Carp (); |
145 | 1104 | use Scalar::Util (); | 1104 | use Scalar::Util qw(looks_like_number blessed); |
146 | 1105 | |||
147 | 1105 | 1106 | ||
148 | 1106 | our %TYPES = ( | 1107 | our %TYPES = ( |
152 | 1107 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1108 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
153 | 1108 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1109 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
154 | 1109 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1110 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
155 | 1110 | Str => sub { defined $_[0] }, | 1111 | Str => sub { defined $_[0] }, |
157 | 1111 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1112 | Object => sub { defined $_[0] && blessed($_[0]) }, |
158 | 1112 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1113 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
159 | 1113 | 1114 | ||
160 | 1114 | map { | 1115 | map { |
161 | @@ -1282,7 +1283,7 @@ | |||
162 | 1282 | $method = sub { | 1283 | $method = sub { |
163 | 1283 | if ( $#_ ) { | 1284 | if ( $#_ ) { |
164 | 1284 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1285 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
166 | 1285 | unless blessed($_[1]) && $_[1]->does($role) | 1286 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
167 | 1286 | } | 1287 | } |
168 | 1287 | goto &$original_method | 1288 | goto &$original_method |
169 | 1288 | }; | 1289 | }; |
170 | 1289 | 1290 | ||
171 | === modified file 'bin/pt-slave-find' | |||
172 | --- bin/pt-slave-find 2012-10-31 09:18:34 +0000 | |||
173 | +++ bin/pt-slave-find 2012-10-31 15:31:23 +0000 | |||
174 | @@ -1080,14 +1080,15 @@ | |||
175 | 1080 | use warnings qw( FATAL all ); | 1080 | use warnings qw( FATAL all ); |
176 | 1081 | 1081 | ||
177 | 1082 | use Carp (); | 1082 | use Carp (); |
179 | 1083 | use Scalar::Util (); | 1083 | use Scalar::Util qw(looks_like_number blessed); |
180 | 1084 | |||
181 | 1084 | 1085 | ||
182 | 1085 | our %TYPES = ( | 1086 | our %TYPES = ( |
186 | 1086 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1087 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
187 | 1087 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1088 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
188 | 1088 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1089 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
189 | 1089 | Str => sub { defined $_[0] }, | 1090 | Str => sub { defined $_[0] }, |
191 | 1090 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1091 | Object => sub { defined $_[0] && blessed($_[0]) }, |
192 | 1091 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1092 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
193 | 1092 | 1093 | ||
194 | 1093 | map { | 1094 | map { |
195 | @@ -1261,7 +1262,7 @@ | |||
196 | 1261 | $method = sub { | 1262 | $method = sub { |
197 | 1262 | if ( $#_ ) { | 1263 | if ( $#_ ) { |
198 | 1263 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1264 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
200 | 1264 | unless blessed($_[1]) && $_[1]->does($role) | 1265 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
201 | 1265 | } | 1266 | } |
202 | 1266 | goto &$original_method | 1267 | goto &$original_method |
203 | 1267 | }; | 1268 | }; |
204 | 1268 | 1269 | ||
205 | === modified file 'bin/pt-slave-restart' | |||
206 | --- bin/pt-slave-restart 2012-10-31 09:18:34 +0000 | |||
207 | +++ bin/pt-slave-restart 2012-10-31 15:31:23 +0000 | |||
208 | @@ -1222,14 +1222,15 @@ | |||
209 | 1222 | use warnings qw( FATAL all ); | 1222 | use warnings qw( FATAL all ); |
210 | 1223 | 1223 | ||
211 | 1224 | use Carp (); | 1224 | use Carp (); |
213 | 1225 | use Scalar::Util (); | 1225 | use Scalar::Util qw(looks_like_number blessed); |
214 | 1226 | |||
215 | 1226 | 1227 | ||
216 | 1227 | our %TYPES = ( | 1228 | our %TYPES = ( |
220 | 1228 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1229 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
221 | 1229 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1230 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
222 | 1230 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1231 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
223 | 1231 | Str => sub { defined $_[0] }, | 1232 | Str => sub { defined $_[0] }, |
225 | 1232 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1233 | Object => sub { defined $_[0] && blessed($_[0]) }, |
226 | 1233 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1234 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
227 | 1234 | 1235 | ||
228 | 1235 | map { | 1236 | map { |
229 | @@ -1403,7 +1404,7 @@ | |||
230 | 1403 | $method = sub { | 1404 | $method = sub { |
231 | 1404 | if ( $#_ ) { | 1405 | if ( $#_ ) { |
232 | 1405 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1406 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
234 | 1406 | unless blessed($_[1]) && $_[1]->does($role) | 1407 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
235 | 1407 | } | 1408 | } |
236 | 1408 | goto &$original_method | 1409 | goto &$original_method |
237 | 1409 | }; | 1410 | }; |
238 | 1410 | 1411 | ||
239 | === modified file 'bin/pt-table-checksum' | |||
240 | --- bin/pt-table-checksum 2012-10-31 09:18:34 +0000 | |||
241 | +++ bin/pt-table-checksum 2012-10-31 15:31:23 +0000 | |||
242 | @@ -2774,14 +2774,15 @@ | |||
243 | 2774 | use warnings qw( FATAL all ); | 2774 | use warnings qw( FATAL all ); |
244 | 2775 | 2775 | ||
245 | 2776 | use Carp (); | 2776 | use Carp (); |
247 | 2777 | use Scalar::Util (); | 2777 | use Scalar::Util qw(looks_like_number blessed); |
248 | 2778 | |||
249 | 2778 | 2779 | ||
250 | 2779 | our %TYPES = ( | 2780 | our %TYPES = ( |
254 | 2780 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 2781 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
255 | 2781 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 2782 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
256 | 2782 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 2783 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
257 | 2783 | Str => sub { defined $_[0] }, | 2784 | Str => sub { defined $_[0] }, |
259 | 2784 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 2785 | Object => sub { defined $_[0] && blessed($_[0]) }, |
260 | 2785 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 2786 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
261 | 2786 | 2787 | ||
262 | 2787 | map { | 2788 | map { |
263 | @@ -2955,7 +2956,7 @@ | |||
264 | 2955 | $method = sub { | 2956 | $method = sub { |
265 | 2956 | if ( $#_ ) { | 2957 | if ( $#_ ) { |
266 | 2957 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 2958 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
268 | 2958 | unless blessed($_[1]) && $_[1]->does($role) | 2959 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
269 | 2959 | } | 2960 | } |
270 | 2960 | goto &$original_method | 2961 | goto &$original_method |
271 | 2961 | }; | 2962 | }; |
272 | 2962 | 2963 | ||
273 | === modified file 'bin/pt-variable-advisor' | |||
274 | --- bin/pt-variable-advisor 2012-10-31 09:18:34 +0000 | |||
275 | +++ bin/pt-variable-advisor 2012-10-31 15:31:23 +0000 | |||
276 | @@ -1105,14 +1105,15 @@ | |||
277 | 1105 | use warnings qw( FATAL all ); | 1105 | use warnings qw( FATAL all ); |
278 | 1106 | 1106 | ||
279 | 1107 | use Carp (); | 1107 | use Carp (); |
281 | 1108 | use Scalar::Util (); | 1108 | use Scalar::Util qw(looks_like_number blessed); |
282 | 1109 | |||
283 | 1109 | 1110 | ||
284 | 1110 | our %TYPES = ( | 1111 | our %TYPES = ( |
288 | 1111 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 1112 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
289 | 1112 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 1113 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
290 | 1113 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 1114 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
291 | 1114 | Str => sub { defined $_[0] }, | 1115 | Str => sub { defined $_[0] }, |
293 | 1115 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 1116 | Object => sub { defined $_[0] && blessed($_[0]) }, |
294 | 1116 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 1117 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
295 | 1117 | 1118 | ||
296 | 1118 | map { | 1119 | map { |
297 | @@ -1286,7 +1287,7 @@ | |||
298 | 1286 | $method = sub { | 1287 | $method = sub { |
299 | 1287 | if ( $#_ ) { | 1288 | if ( $#_ ) { |
300 | 1288 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 1289 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
302 | 1289 | unless blessed($_[1]) && $_[1]->does($role) | 1290 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
303 | 1290 | } | 1291 | } |
304 | 1291 | goto &$original_method | 1292 | goto &$original_method |
305 | 1292 | }; | 1293 | }; |
306 | 1293 | 1294 | ||
307 | === modified file 'lib/Mo.pm' | |||
308 | --- lib/Mo.pm 2012-07-11 18:04:50 +0000 | |||
309 | +++ lib/Mo.pm 2012-10-31 15:31:23 +0000 | |||
310 | @@ -41,19 +41,19 @@ | |||
311 | 41 | use warnings qw( FATAL all ); | 41 | use warnings qw( FATAL all ); |
312 | 42 | 42 | ||
313 | 43 | use Carp (); | 43 | use Carp (); |
315 | 44 | use Scalar::Util (); | 44 | use Scalar::Util qw(looks_like_number blessed); |
316 | 45 | 45 | ||
317 | 46 | # Basic types for isa. If you want a new type, either add it here, | 46 | # Basic types for isa. If you want a new type, either add it here, |
318 | 47 | # or give isa a coderef. | 47 | # or give isa a coderef. |
319 | 48 | |||
320 | 48 | our %TYPES = ( | 49 | our %TYPES = ( |
324 | 49 | Bool => sub { !$_[0] || (defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == 1) }, | 50 | Bool => sub { !$_[0] || (defined $_[0] && looks_like_number($_[0]) && $_[0] == 1) }, |
325 | 50 | Num => sub { defined $_[0] && &Scalar::Util::looks_like_number }, | 51 | Num => sub { defined $_[0] && looks_like_number($_[0]) }, |
326 | 51 | Int => sub { defined $_[0] && &Scalar::Util::looks_like_number && $_[0] == int $_[0] }, | 52 | Int => sub { defined $_[0] && looks_like_number($_[0]) && $_[0] == int($_[0]) }, |
327 | 52 | Str => sub { defined $_[0] }, | 53 | Str => sub { defined $_[0] }, |
329 | 53 | Object => sub { defined $_[0] && &Scalar::Util::blessed }, | 54 | Object => sub { defined $_[0] && blessed($_[0]) }, |
330 | 54 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, | 55 | FileHandle => sub { local $@; require IO::Handle; fileno($_[0]) && $_[0]->opened }, |
331 | 55 | 56 | ||
332 | 56 | # Ref types: | ||
333 | 57 | map { | 57 | map { |
334 | 58 | my $type = /R/ ? $_ : uc $_; | 58 | my $type = /R/ ? $_ : uc $_; |
335 | 59 | $_ . "Ref" => sub { ref $_[0] eq $type } | 59 | $_ . "Ref" => sub { ref $_[0] eq $type } |
336 | @@ -245,7 +245,7 @@ | |||
337 | 245 | $method = sub { | 245 | $method = sub { |
338 | 246 | if ( $#_ ) { | 246 | if ( $#_ ) { |
339 | 247 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) | 247 | Carp::confess(qq<Attribute ($attribute) doesn't consume a '$role' role">) |
341 | 248 | unless blessed($_[1]) && $_[1]->does($role) | 248 | unless Scalar::Util::blessed($_[1]) && eval { $_[1]->does($role) } |
342 | 249 | } | 249 | } |
343 | 250 | goto &$original_method | 250 | goto &$original_method |
344 | 251 | }; | 251 | }; |
345 | 252 | 252 | ||
346 | === modified file 't/lib/Mo/isa.t' | |||
347 | --- t/lib/Mo/isa.t 2012-07-19 21:38:35 +0000 | |||
348 | +++ t/lib/Mo/isa.t 2012-10-31 15:31:23 +0000 | |||
349 | @@ -9,6 +9,7 @@ | |||
350 | 9 | use strict; | 9 | use strict; |
351 | 10 | use warnings FATAL => 'all'; | 10 | use warnings FATAL => 'all'; |
352 | 11 | use English qw(-no_match_vars); | 11 | use English qw(-no_match_vars); |
353 | 12 | use PerconaTest (); | ||
354 | 12 | use Test::More; | 13 | use Test::More; |
355 | 13 | 14 | ||
356 | 14 | sub dies_ok (&;$) { | 15 | sub dies_ok (&;$) { |
357 | @@ -182,4 +183,19 @@ | |||
358 | 182 | my $method = "my$type"; | 183 | my $method = "my$type"; |
359 | 183 | dies_ok { $foo->$method(undef) } "$type attr set to undef dies" } | 184 | dies_ok { $foo->$method(undef) } "$type attr set to undef dies" } |
360 | 184 | 185 | ||
361 | 186 | |||
362 | 187 | use Config; | ||
363 | 188 | use File::Spec; | ||
364 | 189 | use IPC::Cmd (); | ||
365 | 190 | my $thisperl = $^X; | ||
366 | 191 | if ($^O ne 'VMS') | ||
367 | 192 | {$thisperl .= $Config{_exe} unless $thisperl =~ m/$Config{_exe}$/i;} | ||
368 | 193 | |||
369 | 194 | my $pm_test = File::Spec->catfile($PerconaTest::trunk, qw(t lib Mo isa_subtest.pm)); | ||
370 | 195 | |||
371 | 196 | ok( | ||
372 | 197 | scalar(IPC::Cmd::run(command => [$thisperl, $pm_test])), | ||
373 | 198 | "Mo types work with Scalar::Util::PP", | ||
374 | 199 | ); | ||
375 | 200 | |||
376 | 185 | done_testing; | 201 | done_testing; |
377 | 186 | 202 | ||
378 | === added file 't/lib/Mo/isa_subtest.pm' | |||
379 | --- t/lib/Mo/isa_subtest.pm 1970-01-01 00:00:00 +0000 | |||
380 | +++ t/lib/Mo/isa_subtest.pm 2012-10-31 15:31:23 +0000 | |||
381 | @@ -0,0 +1,28 @@ | |||
382 | 1 | BEGIN { | ||
383 | 2 | require Scalar::Util::PP; | ||
384 | 3 | *Scalar::Util:: = \*Scalar::Util::PP::; | ||
385 | 4 | $INC{"Scalar/Util.pm"} = __FILE__; | ||
386 | 5 | }; | ||
387 | 6 | |||
388 | 7 | BEGIN { | ||
389 | 8 | die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n" | ||
390 | 9 | unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH}; | ||
391 | 10 | unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib"; | ||
392 | 11 | }; | ||
393 | 12 | |||
394 | 13 | use strict; | ||
395 | 14 | use warnings; | ||
396 | 15 | |||
397 | 16 | { | ||
398 | 17 | package isa_subtest; | ||
399 | 18 | use Mo; | ||
400 | 19 | |||
401 | 20 | has attr => ( | ||
402 | 21 | is => 'rw', | ||
403 | 22 | isa => 'Int', | ||
404 | 23 | ); | ||
405 | 24 | |||
406 | 25 | 1; | ||
407 | 26 | } | ||
408 | 27 | |||
409 | 28 | isa_subtest->new(attr => 100); |
+my $pm_test = File::Spec- >catfile( $PerconaTest: :trunk, qw(t lib Mo isa_subtest.pm));
both otherwise it passes tests.