From 5672d44892c4010cdfbdc46f5fb29259fa51e076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 10 Sep 2023 17:07:56 +0200 Subject: Add `break` and `continue` support in `for`. --- tests/test/util.scm | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'tests/test') diff --git a/tests/test/util.scm b/tests/test/util.scm index 719afbed..b25c9add 100644 --- a/tests/test/util.scm +++ b/tests/test/util.scm @@ -39,15 +39,30 @@ (awhen (memv 0 '(1 2 3 4 5)) (cdr it))) -(test-equal "for simple" - (iota 10) - (for x in (iota 10) - x)) - -(test-equal "for matching" - (iota 12) - (for (x c) in (zip (iota 12) (string->list "Hello, World")) - x)) +(test-group "for" + (test-equal "for simple" + (iota 10) + (for x in (iota 10) + x)) + + (test-equal "for matching" + (iota 12) + (for (x c) in (zip (iota 12) (string->list "Hello, World")) + x)) + + (test-equal "for break" + 'x + (for x in (iota 10) + (break 'x) + (test-assert "This should never happen" #f))) + + (test-equal "for continue" + '(x #f 2) + (for x in (iota 3) + (case x + ((0) (continue 'x)) + ((1) (continue)) + (else x))))) (test-equal "procedure label" 120 -- cgit v1.2.3