From a4178c29f7151a27ef5a2de0cea31d0c9c51ac57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 29 Jun 2022 14:19:44 +0200 Subject: Add split-by-one-of. A rather peculiar procedure, but "needed" to implement order of operations on a flat list. --- tests/test/util.scm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3