From becfaeb778a3c8ba241e2155b998d6b27dcfad0c Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 26 Jul 2022 19:24:10 -0700 Subject: Fix a potential R7RS issue. I was using the load procedure to load a program, but by a strict reading of R7RS, load can only handle expressions and definitions, not imports. So instead I'm defining each test as a library, and using the environment procedure to load them at runtime. --- csc/strings-test.csc | 118 ++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 58 deletions(-) (limited to 'csc/strings-test.csc') diff --git a/csc/strings-test.csc b/csc/strings-test.csc index 49f8d20..c3dd378 100644 --- a/csc/strings-test.csc +++ b/csc/strings-test.csc @@ -1,95 +1,97 @@ -(import (scheme base) - (only (csc testing) - assert - assert-equal - test) - (csc strings)) +(define-library (csc strings-test) + (import (scheme base) + (only (csc testing) + assert + assert-equal + test) + (csc strings)) + (begin -(test prefix?-good - (assert-equal #t (prefix? "asdf" "asdfjkl;"))) + (test prefix?-good + (assert-equal #t (prefix? "asdf" "asdfjkl;"))) -(test prefix?-bad - (assert-equal #f (prefix? "asdf" "asdbjkl;"))) + (test prefix?-bad + (assert-equal #f (prefix? "asdf" "asdbjkl;"))) -(test prefix?-too-long - (assert-equal #f (prefix? "asdf" "as"))) + (test prefix?-too-long + (assert-equal #f (prefix? "asdf" "as"))) -(test str-quote-simple - (assert-equal "\"hello\"" (str-quote "hello"))) + (test str-quote-simple + (assert-equal "\"hello\"" (str-quote "hello"))) -(test str-quote-escape - (assert-equal "\"this string \\\" has a quote\"" (str-quote "this string \" has a quote"))) + (test str-quote-escape + (assert-equal "\"this string \\\" has a quote\"" (str-quote "this string \" has a quote"))) -(test find-ok - (assert-equal 8 (find "abc" "dabsadfdabcdfdfd"))) + (test find-ok + (assert-equal 8 (find "abc" "dabsadfdabcdfdfd"))) -(test find-one-letter - (assert-equal 8 (find "a" "sdfdfdfsasdfe"))) + (test find-one-letter + (assert-equal 8 (find "a" "sdfdfdfsasdfe"))) -(test find-notfound - (let* ((match "a") - (str "def") - (got-exception '())) - (guard (e - ((not-found-error? e) (set! got-exception e))) - (find match str)) - (assert (not-found-error? got-exception)))) + (test find-notfound + (let* ((match "a") + (str "def") + (got-exception '())) + (guard (e + ((not-found-error? e) (set! got-exception e))) + (find match str)) + (assert (not-found-error? got-exception)))) -(test contains - (assert-equal - #t - (contains "abc" "b"))) + (test contains + (assert-equal + #t + (contains "abc" "b"))) -(test doesnt-contain - (assert-equal - #f - (contains "abc" "d"))) + (test doesnt-contain + (assert-equal + #f + (contains "abc" "d"))) -(test contains-empty - (assert-equal - #t - (contains "" ""))) + (test contains-empty + (assert-equal + #t + (contains "" ""))) -(test empty-contains - (assert-equal - #f - (contains "" "a"))) + (test empty-contains + (assert-equal + #f + (contains "" "a"))) -(test join-, - (assert-equal "a,b,c" (join "," "a" "b" "c"))) + (test join-, + (assert-equal "a,b,c" (join "," "a" "b" "c"))) -(test join-none - (assert-equal "" (join ","))) + (test join-none + (assert-equal "" (join ","))) -(test join-singleton - (assert-equal "x" (join "," "x"))) + (test join-singleton + (assert-equal "x" (join "," "x"))) -(test join-empty - (assert-equal "abc" (join "" "a" "b" "c"))) + (test join-empty + (assert-equal "abc" (join "" "a" "b" "c"))) -(test split-empty - (assert-equal '("") (split "" " "))) + (test split-empty + (assert-equal '("") (split "" " "))) -(test split - (assert-equal '("a" "b") (split "a b" " "))) + (test split + (assert-equal '("a" "b") (split "a b" " "))) -(test split-trailing-empty - (assert-equal '("a" "") (split "a " " "))) + (test split-trailing-empty + (assert-equal '("a" "") (split "a " " "))))) -- cgit v1.3.1