• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revision1a458faeb6265b283f347072fba9b8e39e4898e8 (tree)
Time2023-03-17 22:26:59
Authormiyakawataku
Commitermiyakawataku

Log Message

replace CONTROL.try in tests of CORE mod

Change Summary

Incremental Difference

diff -r 59104b25d065 -r 1a458faeb626 src/test/kink/CORE_test.kn
--- a/src/test/kink/CORE_test.kn Fri Mar 17 22:14:20 2023 +0900
+++ b/src/test/kink/CORE_test.kn Fri Mar 17 22:26:59 2023 +0900
@@ -61,11 +61,11 @@
6161
6262 TEST.group('CORE.reraise'){ # {{{1
6363 TEST.test('alternative message for non-str argument'){
64- CONTROL.try(
64+ CONTROL.xtry(
6565 { reraise(42 []) }
6666 {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) }
67- {(:Msg :Traces)
68- Msg == 'exception message is not str' || raise('got Msg {}'.format(Msg.repr))
67+ {(:Exc)
68+ Exc.message == 'exception message is not str' || Exc.raise
6969 }
7070 )
7171 }
@@ -145,11 +145,12 @@
145145 TEST.test('raises an exception if not found'){
146146 save_mod_paths{
147147 MOD.append_path('src/test/kink/mod_base/path_y')
148- CONTROL.try(
148+ CONTROL.xtry(
149149 { require('dir/NO_SUCH_MOD') }
150150 {(:R) raise('got {}'.format(R.repr)) }
151- {(:Msg :Traces)
152- Msg.have_slice?('CORE.require') && Msg.have_slice?('NO_SUCH_MOD') || reraise(Msg Traces)
151+ {(:Exc)
152+ :Msg = Exc.message
153+ Msg.have_slice?('CORE.require') && Msg.have_slice?('NO_SUCH_MOD') || Exc.raise
153154 }
154155 )
155156 }
@@ -158,11 +159,12 @@
158159 TEST.test('raises an exception if not found, with empty config'){
159160 save_mod_paths{
160161 MOD.append_path('src/test/kink/mod_base/path_y')
161- CONTROL.try(
162+ CONTROL.xtry(
162163 { require('dir/NO_SUCH_MOD'){} }
163164 {(:R) raise('got {}'.format(R.repr)) }
164- {(:Msg :Traces)
165- Msg.have_slice?('CORE.require') && Msg.have_slice?('NO_SUCH_MOD') || reraise(Msg Traces)
165+ {(:Exc)
166+ :Msg = Exc.message
167+ Msg.have_slice?('CORE.require') && Msg.have_slice?('NO_SUCH_MOD') || Exc.raise
166168 }
167169 )
168170 }
@@ -182,11 +184,12 @@
182184 TEST.test('raises an exception on a compile error'){
183185 save_mod_paths{
184186 MOD.append_path('src/test/kink/mod_base/path_x')
185- CONTROL.try(
187+ CONTROL.xtry(
186188 { require('dir/COMPILE_ERROR') }
187189 {(:R) raise('got {}'.format(R.repr)) }
188- {(:Msg :Traces)
189- Msg.have_slice?('CORE.require') && Msg.have_slice?('COMPILE_ERROR') || reraise(Msg Traces)
190+ {(:Exc)
191+ :Msg = Exc.message
192+ Msg.have_slice?('CORE.require') && Msg.have_slice?('COMPILE_ERROR') || Exc.raise
190193 }
191194 )
192195 }
@@ -195,11 +198,12 @@
195198 TEST.test('raises an exception on a compile error, with empty config'){
196199 save_mod_paths{
197200 MOD.append_path('src/test/kink/mod_base/path_x')
198- CONTROL.try(
201+ CONTROL.xtry(
199202 { require('dir/COMPILE_ERROR'){} }
200203 {(:R) raise('got {}'.format(R.repr)) }
201- {(:Msg :Traces)
202- Msg.have_slice?('CORE.require') && Msg.have_slice?('COMPILE_ERROR') || reraise(Msg Traces)
204+ {(:Exc)
205+ :Msg = Exc.message
206+ Msg.have_slice?('CORE.require') && Msg.have_slice?('COMPILE_ERROR') || Exc.raise
203207 }
204208 )
205209 }
@@ -219,11 +223,12 @@
219223 }
220224
221225 TEST.test('raises an exception on a bad name'){
222- CONTROL.try(
226+ CONTROL.xtry(
223227 { require('bad Name') }
224228 {(:R) raise('got {}'.format(R.repr)) }
225- {(:Msg :Traces)
226- Msg.have_slice?('CORE.require') && Msg.have_slice?('bad Name') || reraise(Msg Traces)
229+ {(:Exc)
230+ :Msg = Exc.message
231+ Msg.have_slice?('CORE.require') && Msg.have_slice?('bad Name') || Exc.raise
227232 }
228233 )
229234 }
@@ -252,11 +257,12 @@
252257 # }}}2
253258 TEST.group('checks the mod name'){ # {{{2
254259 TEST.test('is a str'){
255- CONTROL.try(
260+ CONTROL.xtry(
256261 { require(nada) }
257262 {(:R) raise('got {}'.format(R.repr)) }
258- {(:Msg :Traces)
259- Msg.have_slice?('CORE.require') && Msg.have_slice?('nada') || reraise(Msg Traces)
263+ {(:Exc)
264+ :Msg = Exc.message
265+ Msg.have_slice?('CORE.require') && Msg.have_slice?('nada') || Exc.raise
260266 }
261267 )
262268 }
@@ -265,11 +271,12 @@
265271 # }}}2
266272 TEST.group('checks $config'){ # {{{2
267273 TEST.test('is a fun'){
268- CONTROL.try(
274+ CONTROL.xtry(
269275 { require('kink/CORE' nada) }
270276 {(:R) raise('got {}'.format(R.repr)) }
271- {(:Msg :Traces)
272- Msg.have_slice?('CORE.require') && Msg.have_slice?('nada') || reraise(Msg Traces)
277+ {(:Exc)
278+ :Msg = Exc.message
279+ Msg.have_slice?('CORE.require') && Msg.have_slice?('nada') || Exc.raise
273280 }
274281 )
275282 }
@@ -293,11 +300,12 @@
293300 }
294301
295302 TEST.test('op_lognot non-bool result in exception'){
296- CONTROL.try(
303+ CONTROL.xtry(
297304 { op_lognot(nada) }
298305 {(:Result) raise('got {}'.format(Result.repr)) }
299- {(:Msg :Traces)
300- Msg.have_slice?('nada') && Msg.have_slice?('op_lognot') || reraise(Msg Traces)
306+ {(:Exc)
307+ :Msg = Exc.message
308+ Msg.have_slice?('nada') && Msg.have_slice?('op_lognot') || Exc.raise
301309 }
302310 )
303311 }
@@ -330,21 +338,23 @@
330338 }
331339
332340 TEST.test('expect bool for the first arg'){
333- CONTROL.try(
341+ CONTROL.xtry(
334342 { op_logor(nada { true }) }
335343 {(:R) raise('got {}'.format(R.repr)) }
336- {(:Msg :Traces)
337- Msg.have_slice?('nada') && Msg.have_slice?('op_logor') || reraise(Msg Traces)
344+ {(:Exc)
345+ :Msg = Exc.message
346+ Msg.have_slice?('nada') && Msg.have_slice?('op_logor') || Exc.raise
338347 }
339348 )
340349 }
341350
342351 TEST.test('expect fun for the second arg'){
343- CONTROL.try(
352+ CONTROL.xtry(
344353 { op_logor(true nada) }
345354 {(:R) raise('got {}'.format(R.repr)) }
346- {(:Msg :Traces)
347- Msg.have_slice?('nada') && Msg.have_slice?('op_logor') || reraise(Msg Traces)
355+ {(:Exc)
356+ :Msg = Exc.message
357+ Msg.have_slice?('nada') && Msg.have_slice?('op_logor') || Exc.raise
348358 }
349359 )
350360 }
@@ -377,21 +387,23 @@
377387 }
378388
379389 TEST.test('expect bool for the first arg'){
380- CONTROL.try(
390+ CONTROL.xtry(
381391 { op_logand(nada { true }) }
382392 {(:R) raise('got {}'.format(R.repr)) }
383- {(:Msg :Traces)
384- Msg.have_slice?('nada') && Msg.have_slice?('op_logand') || reraise(Msg Traces)
393+ {(:Exc)
394+ :Msg = Exc.message
395+ Msg.have_slice?('nada') && Msg.have_slice?('op_logand') || Exc.raise
385396 }
386397 )
387398 }
388399
389400 TEST.test('expect fun for the second arg'){
390- CONTROL.try(
401+ CONTROL.xtry(
391402 { op_logand(true nada) }
392403 {(:R) raise('got {}'.format(R.repr)) }
393- {(:Msg :Traces)
394- Msg.have_slice?('nada') && Msg.have_slice?('op_logand') || reraise(Msg Traces)
404+ {(:Exc)
405+ :Msg = Exc.message
406+ Msg.have_slice?('nada') && Msg.have_slice?('op_logand') || Exc.raise
395407 }
396408 )
397409 }
@@ -416,21 +428,23 @@
416428 }
417429
418430 TEST.test('bool must be a bool'){
419- CONTROL.try(
431+ CONTROL.xtry(
420432 { CORE.if(nada {}) }
421433 {(:R) raise('got {}'.format(R.repr)) }
422- {(:Msg :Traces)
423- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
434+ {(:Exc)
435+ :Msg = Exc.message
436+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
424437 }
425438 )
426439 }
427440
428441 TEST.test('$true_cont must be a fun'){
429- CONTROL.try(
442+ CONTROL.xtry(
430443 { CORE.if(true nada) }
431444 {(:R) raise('got {}'.format(R.repr)) }
432- {(:Msg :Traces)
433- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
445+ {(:Exc)
446+ :Msg = Exc.message
447+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
434448 }
435449 )
436450 }
@@ -450,31 +464,34 @@
450464 }
451465
452466 TEST.test('bool must be a bool'){
453- CONTROL.try(
467+ CONTROL.xtry(
454468 { CORE.if(nada {} {}) }
455469 {(:R) raise('got {}'.format(R.repr)) }
456- {(:Msg :Traces)
457- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
470+ {(:Exc)
471+ :Msg = Exc.message
472+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
458473 }
459474 )
460475 }
461476
462477 TEST.test('$true_cont must be a fun'){
463- CONTROL.try(
478+ CONTROL.xtry(
464479 { CORE.if(true nada {}) }
465480 {(:R) raise('got {}'.format(R.repr)) }
466- {(:Msg :Traces)
467- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
481+ {(:Exc)
482+ :Msg = Exc.message
483+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
468484 }
469485 )
470486 }
471487
472488 TEST.test('$false_cont must be a fun'){
473- CONTROL.try(
489+ CONTROL.xtry(
474490 { CORE.if(false {} nada) }
475491 {(:R) raise('got {}'.format(R.repr)) }
476- {(:Msg :Traces)
477- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
492+ {(:Exc)
493+ :Msg = Exc.message
494+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
478495 }
479496 )
480497 }
@@ -497,11 +514,12 @@
497514
498515 TEST.test('bool must be a bool'){
499516 :Nada = nada
500- CONTROL.try(
517+ CONTROL.xtry(
501518 { if(Nada {}) }
502519 {(:R) raise('got {}'.format(R.repr)) }
503- {(:Msg :Traces)
504- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
520+ {(:Exc)
521+ :Msg = Exc.message
522+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
505523 }
506524 )
507525 }
@@ -522,11 +540,12 @@
522540
523541 TEST.test('bool must be a bool'){
524542 :Nada = nada
525- CONTROL.try(
543+ CONTROL.xtry(
526544 { if(Nada {} {}) }
527545 {(:R) raise('got {}'.format(R.repr)) }
528- {(:Msg :Traces)
529- Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || reraise(Msg Traces)
546+ {(:Exc)
547+ :Msg = Exc.message
548+ Msg.have_slice?('nada') && Msg.have_slice?('CORE.if') || Exc.raise
530549 }
531550 )
532551 }
@@ -542,21 +561,21 @@
542561 Result == 'OK' || raise('got {}'.format(Result.repr))
543562 }
544563 TEST.test('not matched'){
545- CONTROL.try(
564+ CONTROL.xtry(
546565 { branch({ false } { raise('not reach here') }) }
547566 {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) }
548- {(:Msg :Traces)
549- Msg.have_slice?('no matching cond') || reraise(Msg Traces)
567+ {(:Exc)
568+ Exc.message.have_slice?('no matching cond') || Exc.raise
550569 }
551570 )
552571 }
553572 TEST.ignore_test('not bool cond'){
554- CONTROL.try(
573+ CONTROL.xtry(
555574 { branch({ false } { raise('not reach here') } { 42 } { raise('not reach here') }) }
556575 {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) }
557- {(:Msg :Traces)
558- Msg == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): result of $cond2 must be bool, but got 42'
559- || reraise(Msg Traces)
576+ {(:Exc)
577+ Exc.message == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): result of $cond2 must be bool, but got 42'
578+ || Exc.raise
560579 }
561580 )
562581 }
@@ -579,12 +598,12 @@
579598 Result == 'Else' || raise('got {}'.format(Result.repr))
580599 }
581600 TEST.ignore_test('not bool cond'){
582- CONTROL.try(
601+ CONTROL.xtry(
583602 { branch({ false } { 'F' } { 42 } { 'T' } $true { 'Else' }) }
584603 {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) }
585- {(:Msg :Traces)
586- Msg == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): result of $cond2 must be bool, but got 42'
587- || reraise(Msg Traces)
604+ {(:Exc)
605+ Exc.message == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): result of $cond2 must be bool, but got 42'
606+ || Exc.raise
588607 }
589608 )
590609 }
@@ -597,11 +616,11 @@
597616 }
598617 TEST.test('slowpath because $true is modified'){
599618 :true = { false }
600- CONTROL.try(
619+ CONTROL.xtry(
601620 { branch({ false } { 'F' } $true { 'F' }) }
602621 {(:Result) raise('expected an exception, but got {}'.format(Result.repr)) }
603- {(:Msg :Traces)
604- Msg == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): no matching cond' || reraise(Msg Traces)
622+ {(:Exc)
623+ Exc.message == 'CORE.branch(...[$cond1 $then1 $cond2 $then2 ,,,]): no matching cond' || Exc.raise
605624 }
606625 )
607626 }
Show on old repository browser