aboutsummaryrefslogtreecommitdiff
path: root/tests/test/util.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-29 14:19:44 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 21:17:22 +0200
commita4178c29f7151a27ef5a2de0cea31d0c9c51ac57 (patch)
tree6c1755c496ce73828c439f35287018074ffb3b42 /tests/test/util.scm
parentMajor work on c parser. (diff)
downloadcalp-a4178c29f7151a27ef5a2de0cea31d0c9c51ac57.tar.gz
calp-a4178c29f7151a27ef5a2de0cea31d0c9c51ac57.tar.xz
Add split-by-one-of.
A rather peculiar procedure, but "needed" to implement order of operations on a flat list.
Diffstat (limited to '')
-rw-r--r--tests/test/util.scm19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test/util.scm b/tests/test/util.scm
index 1de96a37..aa37d20c 100644
--- a/tests/test/util.scm
+++ b/tests/test/util.scm
@@ -187,6 +187,25 @@
(test-error 'wrong-type-arg (find-extreme '()))
+;; TODO group-by
+;; TODO split-by
+
+(test-group "Split-by-one-of"
+
+ (test-equal "Empty input"
+ '(()) (split-by-one-of '() '(+)))
+
+ (test-equal "No matching tokens"
+ '((1 + 2)) (split-by-one-of '(1 + 2) '(/)))
+
+ (test-equal "Matching tokens"
+ '((1) (+ 2) (- 3))
+ (split-by-one-of '(1 + 2 - 3) '(+ -)))
+
+ (test-equal "Maching tokens, multiple values in each group"
+ '((1 + 2) (* 3 + 4))
+ (split-by-one-of '(1 + 2 * 3 + 4) '(*))))
+
(call-with-values
(lambda ()
(span-upto