From 6b8be199ae88979e508f98fb8a8b6fc17c2a7f2d Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 9 Jan 2022 13:17:20 -0800 Subject: Define helper intercalate. --- list-test.csc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'list-test.csc') diff --git a/list-test.csc b/list-test.csc index ec4b4ed..e4981e5 100644 --- a/list-test.csc +++ b/list-test.csc @@ -125,3 +125,35 @@ (unless (equal? got (want tc)) (errorf t "(revappend {} {}) = {}, want {}." (a tc) (b tc) got (want tc))))) tests))) + + +(define-test (test-intercalate t) + (define-record-type + (test-case desc x l want) + test-case? + (desc desc) + (x x) + (l l) + (want want)) + (let ((tests (list + (test-case + "simple" + "," + '("a" "b" "c") + '("a" "," "b" "," "c")) + (test-case + "empty" + "," + '() + '()) + (test-case + "singleton" + "," + '(1) + '(1))))) + (for-each + (lambda (tc) + (let ((got (intercalate (x tc) (l tc)))) + (unless (equal? got (want tc)) + (errorf t "(intercalate {} {}) = {}, want {}." (x tc) (l tc) got (want tc))))) + tests))) -- cgit v1.3.1