Revision | b0a1b6e5e0c43b7873e08faa8109858ccbc89000 (tree) |
---|---|
Time | 2023-03-16 22:04:06 |
Author | miyakawataku |
Commiter | miyakawataku |
replace CONTROL.try in tests of num vals
@@ -44,41 +44,45 @@ | ||
44 | 44 | :op = VARREF.new(Num_div Op_name).load |
45 | 45 | |
46 | 46 | TEST.test('is a num, in {}'.format(Op_name)){ |
47 | - CONTROL.try( | |
47 | + CONTROL.xtry( | |
48 | 48 | { op[Num_div](nada) } |
49 | 49 | {(:R) raise('got {}'.format(R.repr)) } |
50 | - {(:Msg :Traces) | |
51 | - Msg.have_slice?('.' + Op_name) && Msg.have_slice?('nada') || reraise(Msg Traces) | |
50 | + {(:Exc) | |
51 | + :Msg = Exc.message | |
52 | + Msg.have_slice?('.' + Op_name) && Msg.have_slice?('nada') || Exc.raise | |
52 | 53 | } |
53 | 54 | ) |
54 | 55 | } |
55 | 56 | |
56 | 57 | TEST.test('is an int, in {}'.format(Op_name)){ |
57 | - CONTROL.try( | |
58 | + CONTROL.xtry( | |
58 | 59 | { op[Num_div](0.5) } |
59 | 60 | {(:R) raise('got {}'.format(R.repr)) } |
60 | - {(:Msg :Traces) | |
61 | - Msg.have_slice?('.' + Op_name) && Msg.have_slice?('0.5') || reraise(Msg Traces) | |
61 | + {(:Exc) | |
62 | + :Msg = Exc.message | |
63 | + Msg.have_slice?('.' + Op_name) && Msg.have_slice?('0.5') || Exc.raise | |
62 | 64 | } |
63 | 65 | ) |
64 | 66 | } |
65 | 67 | |
66 | 68 | TEST.test('is greater than or equal to INT_MIN, in {}'.format(Op_name)){ |
67 | - CONTROL.try( | |
69 | + CONTROL.xtry( | |
68 | 70 | { op[Num_div](-2147483649) } |
69 | 71 | {(:R) raise('got {}'.format(R.repr)) } |
70 | - {(:Msg :Traces) | |
71 | - Msg.have_slice?('.' + Op_name) && Msg.have_slice?('-2147483649') || reraise(Msg Traces) | |
72 | + {(:Exc) | |
73 | + :Msg = Exc.message | |
74 | + Msg.have_slice?('.' + Op_name) && Msg.have_slice?('-2147483649') || Exc.raise | |
72 | 75 | } |
73 | 76 | ) |
74 | 77 | } |
75 | 78 | |
76 | 79 | TEST.test('is greater than or equal to INT_MAX, in {}'.format(Op_name)){ |
77 | - CONTROL.try( | |
80 | + CONTROL.xtry( | |
78 | 81 | { op[Num_div](2147483648) } |
79 | 82 | {(:R) raise('got {}'.format(R.repr)) } |
80 | - {(:Msg :Traces) | |
81 | - Msg.have_slice?('.' + Op_name) && Msg.have_slice?('2147483648') || reraise(Msg Traces) | |
83 | + {(:Exc) | |
84 | + :Msg = Exc.message | |
85 | + Msg.have_slice?('.' + Op_name) && Msg.have_slice?('2147483648') || Exc.raise | |
82 | 86 | } |
83 | 87 | ) |
84 | 88 | } |
@@ -227,11 +231,12 @@ | ||
227 | 231 | TEST.group('NUM_DIV.new'){ # {{{1 |
228 | 232 | TEST.group('check Dividend'){ |
229 | 233 | TEST.test('is a num'){ |
230 | - CONTROL.try( | |
234 | + CONTROL.xtry( | |
231 | 235 | { NUM_DIV.new(nada 3) } |
232 | 236 | {(:R) raise('got {}'.format(R.repr)) } |
233 | - {(:Msg :Traces) | |
234 | - Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
237 | + {(:Exc) | |
238 | + :Msg = Exc.message | |
239 | + Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('nada') || Exc.raise | |
235 | 240 | } |
236 | 241 | ) |
237 | 242 | } |
@@ -239,31 +244,34 @@ | ||
239 | 244 | |
240 | 245 | TEST.group('check Divisor'){ |
241 | 246 | TEST.test('is a num'){ |
242 | - CONTROL.try( | |
247 | + CONTROL.xtry( | |
243 | 248 | { NUM_DIV.new(2 nada) } |
244 | 249 | {(:R) raise('got {}'.format(R.repr)) } |
245 | - {(:Msg :Traces) | |
246 | - Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
250 | + {(:Exc) | |
251 | + :Msg = Exc.message | |
252 | + Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('nada') || Exc.raise | |
247 | 253 | } |
248 | 254 | ) |
249 | 255 | } |
250 | 256 | |
251 | 257 | TEST.test('is not zero'){ |
252 | - CONTROL.try( | |
258 | + CONTROL.xtry( | |
253 | 259 | { NUM_DIV.new(2 0) } |
254 | 260 | {(:R) raise('got {}'.format(R.repr)) } |
255 | - {(:Msg :Traces) | |
256 | - Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('0') || reraise(Msg Traces) | |
261 | + {(:Exc) | |
262 | + :Msg = Exc.message | |
263 | + Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('0') || Exc.raise | |
257 | 264 | } |
258 | 265 | ) |
259 | 266 | } |
260 | 267 | |
261 | 268 | TEST.test('is not zero, regardless of scale'){ |
262 | - CONTROL.try( | |
269 | + CONTROL.xtry( | |
263 | 270 | { NUM_DIV.new(2 0.0) } |
264 | 271 | {(:R) raise('got {}'.format(R.repr)) } |
265 | - {(:Msg :Traces) | |
266 | - Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('0.0') || reraise(Msg Traces) | |
272 | + {(:Exc) | |
273 | + :Msg = Exc.message | |
274 | + Msg.have_slice?('NUM_DIV.new') && Msg.have_slice?('0.0') || Exc.raise | |
267 | 275 | } |
268 | 276 | ) |
269 | 277 | } |
@@ -46,21 +46,23 @@ | ||
46 | 46 | |
47 | 47 | TEST.group('check Mantissa'){ |
48 | 48 | TEST.test('is a num'){ |
49 | - CONTROL.try( | |
49 | + CONTROL.xtry( | |
50 | 50 | { NUM.new(nada 2) } |
51 | 51 | {(:R) raise('got {}'.format(R.repr)) } |
52 | - {(:Msg :Traces) | |
53 | - Msg.have_slice?('NUM.new') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
52 | + {(:Exc) | |
53 | + :Msg = Exc.message | |
54 | + Msg.have_slice?('NUM.new') && Msg.have_slice?('nada') || Exc.raise | |
54 | 55 | } |
55 | 56 | ) |
56 | 57 | } |
57 | 58 | |
58 | 59 | TEST.test('is an int'){ |
59 | - CONTROL.try( | |
60 | + CONTROL.xtry( | |
60 | 61 | { NUM.new(1.2 2) } |
61 | 62 | {(:R) raise('got {}'.format(R.repr)) } |
62 | - {(:Msg :Traces) | |
63 | - Msg.have_slice?('NUM.new') && Msg.have_slice?('1.2') || reraise(Msg Traces) | |
63 | + {(:Exc) | |
64 | + :Msg = Exc.message | |
65 | + Msg.have_slice?('NUM.new') && Msg.have_slice?('1.2') || Exc.raise | |
64 | 66 | } |
65 | 67 | ) |
66 | 68 | } |
@@ -68,41 +70,43 @@ | ||
68 | 70 | |
69 | 71 | TEST.group('check Scale'){ |
70 | 72 | TEST.test('is a num'){ |
71 | - CONTROL.try( | |
73 | + CONTROL.xtry( | |
72 | 74 | { NUM.new(12345 nada) } |
73 | 75 | {(:R) raise('got {}'.format(R.repr)) } |
74 | - {(:Msg :Traces) | |
75 | - Msg.have_slice?('NUM.new') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
76 | + {(:Exc) | |
77 | + :Msg = Exc.message | |
78 | + Msg.have_slice?('NUM.new') && Msg.have_slice?('nada') || Exc.raise | |
76 | 79 | } |
77 | 80 | ) |
78 | 81 | } |
79 | 82 | |
80 | 83 | TEST.test('is an int'){ |
81 | - CONTROL.try( | |
84 | + CONTROL.xtry( | |
82 | 85 | { NUM.new(12345 3.14) } |
83 | 86 | {(:R) raise('got {}'.format(R.repr)) } |
84 | - {(:Msg :Traces) | |
85 | - Msg.have_slice?('NUM.new') && Msg.have_slice?('3.14') || reraise(Msg Traces) | |
87 | + {(:Exc) | |
88 | + :Msg = Exc.message | |
89 | + Msg.have_slice?('NUM.new') && Msg.have_slice?('3.14') || Exc.raise | |
86 | 90 | } |
87 | 91 | ) |
88 | 92 | } |
89 | 93 | |
90 | 94 | TEST.test('does not underflow'){ |
91 | - CONTROL.try( | |
95 | + CONTROL.xtry( | |
92 | 96 | { NUM.new(1 (-(1 << 31)) - 1) } |
93 | 97 | {(:R) raise('got {}'.format(R.repr)) } |
94 | - {(:Msg :Traces) | |
95 | - Msg.have_slice?('NUM.new') || reraise(Msg Traces) | |
98 | + {(:Exc) | |
99 | + Exc.message.have_slice?('NUM.new') || Exc.raise | |
96 | 100 | } |
97 | 101 | ) |
98 | 102 | } |
99 | 103 | |
100 | 104 | TEST.test('does not overflow'){ |
101 | - CONTROL.try( | |
105 | + CONTROL.xtry( | |
102 | 106 | { NUM.new(1 1 << 31) } |
103 | 107 | {(:R) raise('got {}'.format(R.repr)) } |
104 | - {(:Msg :Traces) | |
105 | - Msg.have_slice?('NUM.new') || reraise(Msg Traces) | |
108 | + {(:Exc) | |
109 | + Exc.message.have_slice?('NUM.new') || Exc.raise | |
106 | 110 | } |
107 | 111 | ) |
108 | 112 | } |
@@ -156,47 +160,52 @@ | ||
156 | 160 | Result == [] || raise('got {}'.format(Result.repr)) |
157 | 161 | } |
158 | 162 | TEST.test('raise exception for too small radix'){ |
159 | - CONTROL.try( | |
163 | + CONTROL.xtry( | |
160 | 164 | { NUM.parse_int('000' 1) } |
161 | 165 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
162 | - {(:Msg :Traces) | |
163 | - Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('1') || reraise(Msg Traces) | |
166 | + {(:Exc) | |
167 | + :Msg = Exc.message | |
168 | + Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('1') || Exc.raise | |
164 | 169 | } |
165 | 170 | ) |
166 | 171 | } |
167 | 172 | TEST.test('raise exception for too big radix'){ |
168 | - CONTROL.try( | |
173 | + CONTROL.xtry( | |
169 | 174 | { NUM.parse_int('Zzz' 37) } |
170 | 175 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
171 | - {(:Msg :Traces) | |
172 | - Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('37') || reraise(Msg Traces) | |
176 | + {(:Exc) | |
177 | + :Msg = Exc.message | |
178 | + Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('37') || Exc.raise | |
173 | 179 | } |
174 | 180 | ) |
175 | 181 | } |
176 | 182 | TEST.test('raise exception for non-num radix'){ |
177 | - CONTROL.try( | |
183 | + CONTROL.xtry( | |
178 | 184 | { NUM.parse_int('42' nada) } |
179 | 185 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
180 | - {(:Msg :Traces) | |
181 | - Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
186 | + {(:Exc) | |
187 | + :Msg = Exc.message | |
188 | + Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('nada') || Exc.raise | |
182 | 189 | } |
183 | 190 | ) |
184 | 191 | } |
185 | 192 | TEST.test('raise exception for non-int radix'){ |
186 | - CONTROL.try( | |
193 | + CONTROL.xtry( | |
187 | 194 | { NUM.parse_int('42' 3.14) } |
188 | 195 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
189 | - {(:Msg :Traces) | |
190 | - Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('3.14') || reraise(Msg Traces) | |
196 | + {(:Exc) | |
197 | + :Msg = Exc.message | |
198 | + Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('3.14') || Exc.raise | |
191 | 199 | } |
192 | 200 | ) |
193 | 201 | } |
194 | 202 | TEST.test('raise exception for non-str Str'){ |
195 | - CONTROL.try( | |
203 | + CONTROL.xtry( | |
196 | 204 | { NUM.parse_int(nada 10) } |
197 | 205 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
198 | - {(:Msg :Traces) | |
199 | - Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
206 | + {(:Exc) | |
207 | + :Msg = Exc.message | |
208 | + Msg.have_slice?('NUM.parse_int') && Msg.have_slice?('nada') || Exc.raise | |
200 | 209 | } |
201 | 210 | ) |
202 | 211 | } |
@@ -279,11 +288,12 @@ | ||
279 | 288 | } |
280 | 289 | |
281 | 290 | TEST.test('raise an exception if the arg is not str'){ |
282 | - CONTROL.try( | |
291 | + CONTROL.xtry( | |
283 | 292 | { NUM.parse_decimal(nada) } |
284 | 293 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
285 | - {(:Msg :Traces) | |
286 | - Msg.have_slice?('NUM.parse_decimal') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
294 | + {(:Exc) | |
295 | + :Msg = Exc.message | |
296 | + Msg.have_slice?('NUM.parse_decimal') && Msg.have_slice?('nada') || Exc.raise | |
287 | 297 | } |
288 | 298 | ) |
289 | 299 | } |
@@ -306,11 +316,12 @@ | ||
306 | 316 | } |
307 | 317 | |
308 | 318 | TEST.test('checks arg type'){ |
309 | - CONTROL.try( | |
319 | + CONTROL.xtry( | |
310 | 320 | { 42.show{(:C) C.plus_sign(nada) } } |
311 | 321 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
312 | - {(:Msg :Traces) | |
313 | - Msg.have_slice?('.plus_sign') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
322 | + {(:Exc) | |
323 | + :Msg = Exc.message | |
324 | + Msg.have_slice?('.plus_sign') && Msg.have_slice?('nada') || Exc.raise | |
314 | 325 | } |
315 | 326 | ) |
316 | 327 | } |
@@ -332,11 +343,12 @@ | ||
332 | 343 | } |
333 | 344 | |
334 | 345 | TEST.test('checks arg type'){ |
335 | - CONTROL.try( | |
346 | + CONTROL.xtry( | |
336 | 347 | { (-42).show{(:C) C.minus_sign(nada) } } |
337 | 348 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
338 | - {(:Msg :Traces) | |
339 | - Msg.have_slice?('.minus_sign') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
349 | + {(:Exc) | |
350 | + :Msg = Exc.message | |
351 | + Msg.have_slice?('.minus_sign') && Msg.have_slice?('nada') || Exc.raise | |
340 | 352 | } |
341 | 353 | ) |
342 | 354 | } |
@@ -372,22 +384,24 @@ | ||
372 | 384 | } |
373 | 385 | |
374 | 386 | TEST.test('.group_sep checks arg type'){ |
375 | - CONTROL.try( | |
387 | + CONTROL.xtry( | |
376 | 388 | { 42.show{(:C) C.group_sep(nada) } } |
377 | 389 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
378 | - {(:Msg :Traces) | |
379 | - Msg.have_slice?('.group_sep') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
390 | + {(:Exc) | |
391 | + :Msg = Exc.message | |
392 | + Msg.have_slice?('.group_sep') && Msg.have_slice?('nada') || Exc.raise | |
380 | 393 | } |
381 | 394 | ) |
382 | 395 | } |
383 | 396 | |
384 | 397 | [nada 0 1.5].each{(:Len) |
385 | 398 | TEST.test('.group_len checks invalid len {}'.format(Len.repr)){ |
386 | - CONTROL.try( | |
399 | + CONTROL.xtry( | |
387 | 400 | { 12345.show{(:C) C.group_len(Len) } } |
388 | 401 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
389 | - {(:Msg :Traces) | |
390 | - Msg.have_slice?('.group_len') && Msg.have_slice?(Len.repr) || reraise(Msg Traces) | |
402 | + {(:Exc) | |
403 | + :Msg = Exc.message | |
404 | + Msg.have_slice?('.group_len') && Msg.have_slice?(Len.repr) || Exc.raise | |
391 | 405 | } |
392 | 406 | ) |
393 | 407 | } |
@@ -409,11 +423,12 @@ | ||
409 | 423 | } |
410 | 424 | |
411 | 425 | TEST.test('checks the arg is str'){ |
412 | - CONTROL.try( | |
426 | + CONTROL.xtry( | |
413 | 427 | { 42.show{(:C) C.decimal_sep(nada) } } |
414 | 428 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
415 | - {(:Msg :Traces) | |
416 | - Msg.have_slice?('.decimal_sep') && Msg.have_slice?('nada') || reraise(Msg Traces) | |
429 | + {(:Exc) | |
430 | + :Msg = Exc.message | |
431 | + Msg.have_slice?('.decimal_sep') && Msg.have_slice?('nada') || Exc.raise | |
417 | 432 | } |
418 | 433 | ) |
419 | 434 | } |
@@ -456,11 +471,12 @@ | ||
456 | 471 | |
457 | 472 | [nada (-1) 0 1.1].each{(:Len) |
458 | 473 | TEST.test('checks invalid arg {}'.format(Len.repr)){ |
459 | - CONTROL.try( | |
474 | + CONTROL.xtry( | |
460 | 475 | { 42.show{(:C) C.pad_zero(Len) } } |
461 | 476 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
462 | - {(:Msg :Traces) | |
463 | - Msg.have_slice?('.pad_zero') && Msg.have_slice?(Len.repr) || reraise(Msg Traces) | |
477 | + {(:Exc) | |
478 | + :Msg = Exc.message | |
479 | + Msg.have_slice?('.pad_zero') && Msg.have_slice?(Len.repr) || Exc.raise | |
464 | 480 | } |
465 | 481 | ) |
466 | 482 | } |
@@ -492,21 +508,23 @@ | ||
492 | 508 | } |
493 | 509 | |
494 | 510 | TEST.test('rejects positive scale'){ |
495 | - CONTROL.try( | |
511 | + CONTROL.xtry( | |
496 | 512 | { 42.show{(:Conf) Conf.radix(10.000) } } |
497 | 513 | {(:R) raise('got {}'.format(R.repr)) } |
498 | - {(:Msg :Traces) | |
499 | - Msg.have_slice?('.radix') && Msg.have_slice?('10.000') || reraise(Msg Traces) | |
514 | + {(:Exc) | |
515 | + :Msg = Exc.message | |
516 | + Msg.have_slice?('.radix') && Msg.have_slice?('10.000') || Exc.raise | |
500 | 517 | } |
501 | 518 | ) |
502 | 519 | } |
503 | 520 | |
504 | 521 | TEST.test('rejects negative scale'){ |
505 | - CONTROL.try( | |
522 | + CONTROL.xtry( | |
506 | 523 | { 42.show{(:Conf) Conf.radix(NUM.new(1 (-1))) } } |
507 | 524 | {(:R) raise('got {}'.format(R.repr)) } |
508 | - {(:Msg :Traces) | |
509 | - Msg.have_slice?('.radix') && Msg.have_slice?('-1') || reraise(Msg Traces) | |
525 | + {(:Exc) | |
526 | + :Msg = Exc.message | |
527 | + Msg.have_slice?('.radix') && Msg.have_slice?('-1') || Exc.raise | |
510 | 528 | } |
511 | 529 | ) |
512 | 530 | } |
@@ -519,34 +537,37 @@ | ||
519 | 537 | } |
520 | 538 | |
521 | 539 | TEST.test('reject non-int when radix is not 10'){ |
522 | - CONTROL.try( | |
540 | + CONTROL.xtry( | |
523 | 541 | { 3.14.show{(:C) C.radix(16) } } |
524 | 542 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
525 | - {(:Msg :Traces) | |
543 | + {(:Exc) | |
544 | + :Msg = Exc.message | |
526 | 545 | Msg.have_slice?('show') && Msg.have_slice?('3.14') |
527 | - && Msg.have_slice?('16') && Msg.have_slice?('10') || reraise(Msg Traces) | |
546 | + && Msg.have_slice?('16') && Msg.have_slice?('10') || Exc.raise | |
528 | 547 | } |
529 | 548 | ) |
530 | 549 | } |
531 | 550 | |
532 | 551 | TEST.test('reject scale!=0 when radix is not 10'){ |
533 | - CONTROL.try( | |
552 | + CONTROL.xtry( | |
534 | 553 | { 255.00.show{(:C) C.radix(16) } } |
535 | 554 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
536 | - {(:Msg :Traces) | |
555 | + {(:Exc) | |
556 | + :Msg = Exc.message | |
537 | 557 | Msg.have_slice?('show') && Msg.have_slice?('255.00') |
538 | - && Msg.have_slice?('16') && Msg.have_slice?('10') || reraise(Msg Traces) | |
558 | + && Msg.have_slice?('16') && Msg.have_slice?('10') || Exc.raise | |
539 | 559 | } |
540 | 560 | ) |
541 | 561 | } |
542 | 562 | |
543 | 563 | [nada 1 37 10.5].each{(:Invalid_radix) |
544 | 564 | TEST.test('check invalid radix {}'.format(Invalid_radix.repr)){ |
545 | - CONTROL.try( | |
565 | + CONTROL.xtry( | |
546 | 566 | { 42.show{(:C) C.radix(Invalid_radix) } } |
547 | 567 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
548 | - {(:Msg :Traces) | |
549 | - Msg.have_slice?('.radix') && Msg.have_slice?(Invalid_radix.repr) || reraise(Msg Traces) | |
568 | + {(:Exc) | |
569 | + :Msg = Exc.message | |
570 | + Msg.have_slice?('.radix') && Msg.have_slice?(Invalid_radix.repr) || Exc.raise | |
550 | 571 | } |
551 | 572 | ) |
552 | 573 | } |
@@ -612,31 +633,32 @@ | ||
612 | 633 | } |
613 | 634 | |
614 | 635 | TEST.test('reject 0 pad len'){ |
615 | - CONTROL.try( | |
636 | + CONTROL.xtry( | |
616 | 637 | { 0xff.show{(:C) C.spec('00') } } |
617 | 638 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
618 | - {(:Msg :Traces) | |
619 | - Msg.have_slice?('.spec') || reraise(Msg Traces) | |
639 | + {(:Exc) | |
640 | + Exc.message.have_slice?('.spec') || Exc.raise | |
620 | 641 | } |
621 | 642 | ) |
622 | 643 | } |
623 | 644 | |
624 | 645 | TEST.test('check len is specified for pad_zero'){ |
625 | - CONTROL.try( | |
646 | + CONTROL.xtry( | |
626 | 647 | { 0xff.show{(:C) C.spec('0') } } |
627 | 648 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
628 | - {(:Msg :Traces) | |
629 | - Msg.have_slice?('.spec') || reraise(Msg Traces) | |
649 | + {(:Exc) | |
650 | + Exc.message.have_slice?('.spec') || Exc.raise | |
630 | 651 | } |
631 | 652 | ) |
632 | 653 | } |
633 | 654 | |
634 | 655 | TEST.test('check unknown spec'){ |
635 | - CONTROL.try( | |
656 | + CONTROL.xtry( | |
636 | 657 | { 0xff.show{(:C) C.spec(',!!!') } } |
637 | 658 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
638 | - {(:Msg :Traces) | |
639 | - Msg.have_slice?('.spec') && Msg.have_slice?('!!!') || reraise(Msg Traces) | |
659 | + {(:Exc) | |
660 | + :Msg = Exc.message | |
661 | + Msg.have_slice?('.spec') && Msg.have_slice?('!!!') || Exc.raise | |
640 | 662 | } |
641 | 663 | ) |
642 | 664 | } |
@@ -661,11 +683,12 @@ | ||
661 | 683 | } |
662 | 684 | |
663 | 685 | TEST.test('checks that the arg is locale'){ |
664 | - CONTROL.try( | |
686 | + CONTROL.xtry( | |
665 | 687 | { 42.show{(:C) C.locale(nada) } } |
666 | 688 | {(:R) raise('got {}'.format(R.repr)) } |
667 | - {(:Msg :Traces) | |
668 | - Msg.have_slice?('nada') && Msg.have_slice?('.locale') || reraise(Msg Traces) | |
689 | + {(:Exc) | |
690 | + :Msg = Exc.message | |
691 | + Msg.have_slice?('nada') && Msg.have_slice?('.locale') || Exc.raise | |
669 | 692 | } |
670 | 693 | ) |
671 | 694 | } |
@@ -704,13 +727,12 @@ | ||
704 | 727 | # }}}2 |
705 | 728 | |
706 | 729 | TEST.test('._show_num provides Conf, which checks spec is str'){ |
707 | - CONTROL.try( | |
730 | + CONTROL.xtry( | |
708 | 731 | { 42.show{(:S) S.spec(nada) } } |
709 | 732 | {(:Result) raise('expected an exception, but got ' + Result.repr) } |
710 | - {(:Msg :Traces) | |
711 | - Msg.have_slice?('.spec') && Msg.have_slice?('str') || raise( | |
712 | - 'got ' + Msg.repr + ' on ' + Traces.repr | |
713 | - ) | |
733 | + {(:Exc) | |
734 | + :Msg = Exc.message | |
735 | + Msg.have_slice?('.spec') && Msg.have_slice?('str') || Exc.raise | |
714 | 736 | } |
715 | 737 | ) |
716 | 738 | } |
@@ -56,63 +56,58 @@ | ||
56 | 56 | } |
57 | 57 | |
58 | 58 | TEST.test('(-1).times raises an exception'){ |
59 | - CONTROL.try( | |
59 | + CONTROL.xtry( | |
60 | 60 | { (-1).times } |
61 | 61 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
62 | - {(:Msg :Traces) | |
63 | - Msg.have_slice?('Num.times') && Msg.have_slice?('-1') || raise( | |
64 | - 'got Msg {} on {}'.format(Msg.repr Traces.repr) | |
65 | - ) | |
62 | + {(:Exc) | |
63 | + :Msg = Exc.message | |
64 | + Msg.have_slice?('Num.times') && Msg.have_slice?('-1') || Exc.raise | |
66 | 65 | } |
67 | 66 | ) |
68 | 67 | } |
69 | 68 | |
70 | 69 | TEST.test('1.5.times raises an exception'){ |
71 | - CONTROL.try( | |
70 | + CONTROL.xtry( | |
72 | 71 | { 1.5.times } |
73 | 72 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
74 | - {(:Msg :Traces) | |
75 | - Msg.have_slice?('Num.times') && Msg.have_slice?('1.5') || raise( | |
76 | - 'got Msg {} on {}'.format(Msg.repr Traces.repr) | |
77 | - ) | |
73 | + {(:Exc) | |
74 | + :Msg = Exc.message | |
75 | + Msg.have_slice?('Num.times') && Msg.have_slice?('1.5') || Exc.raise | |
78 | 76 | } |
79 | 77 | ) |
80 | 78 | } |
81 | 79 | |
82 | 80 | TEST.test('1.0.times raises an exception'){ |
83 | - CONTROL.try( | |
81 | + CONTROL.xtry( | |
84 | 82 | { 1.0.times } |
85 | 83 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
86 | - {(:Msg :Traces) | |
87 | - Msg.have_slice?('Num.times') && Msg.have_slice?('1.0') || raise( | |
88 | - 'got Msg {} on {}'.format(Msg.repr Traces.repr) | |
89 | - ) | |
84 | + {(:Exc) | |
85 | + :Msg = Exc.message | |
86 | + Msg.have_slice?('Num.times') && Msg.have_slice?('1.0') || Exc.raise | |
90 | 87 | } |
91 | 88 | ) |
92 | 89 | } |
93 | 90 | |
94 | 91 | TEST.test('Num.times.ifun checks the type of $proc'){ |
95 | 92 | :ifun = 10.times.ifun |
96 | - CONTROL.try( | |
93 | + CONTROL.xtry( | |
97 | 94 | { ifun(nada {}) } |
98 | 95 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
99 | - {(:Msg :Traces) | |
100 | - Msg.have_slice?('Num.times-ifun') && Msg.have_slice?('fun') || raise( | |
101 | - 'got Msg {} on {}'.format(Msg.repr Traces.repr) | |
102 | - ) | |
96 | + {(:Exc) | |
97 | + :Msg = Exc.message | |
98 | + Msg.have_slice?('Num.times-ifun') && Msg.have_slice?('fun') || Exc.raise | |
103 | 99 | } |
104 | 100 | ) |
105 | 101 | } |
106 | 102 | |
107 | 103 | TEST.test('Num.times.ifun checks the type of $fin'){ |
108 | 104 | :ifun = 10.times.ifun |
109 | - CONTROL.try( | |
105 | + CONTROL.xtry( | |
110 | 106 | { ifun({(:H :t) } nada) } |
111 | 107 | {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) } |
112 | - {(:Msg :Traces) | |
113 | - Msg.have_slice?('Num.times-ifun') && Msg.have_slice?('fun') || raise( | |
114 | - 'got Msg {} on {}'.format(Msg.repr Traces.repr) | |
115 | - ) | |
108 | + {(:Exc) | |
109 | + :Msg = Exc.message | |
110 | + Msg.have_slice?('Num.times-ifun') && Msg.have_slice?('fun') || Exc.raise | |
116 | 111 | } |
117 | 112 | ) |
118 | 113 | } |
@@ -184,13 +179,11 @@ | ||
184 | 179 | } |
185 | 180 | |
186 | 181 | TEST.test('Num.show checks recv type'){ |
187 | - CONTROL.try( | |
182 | + CONTROL.xtry( | |
188 | 183 | { (-42).show[nada]{} } |
189 | 184 | {(:Result) raise('expected an exception, but got ' + Result.repr) } |
190 | - {(:Msg :Traces) | |
191 | - Msg.have_slice?('Num.show') || raise( | |
192 | - 'expected Msg containing "Num.show" but got ' + Msg.repr + ' on ' + Traces.repr | |
193 | - ) | |
185 | + {(:Exc) | |
186 | + Exc.message.have_slice?('Num.show') || Exc.raise | |
194 | 187 | } |
195 | 188 | ) |
196 | 189 | } |