aboutsummaryrefslogtreecommitdiffstats
path: root/csc/strings-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-26 19:24:10 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-26 19:24:10 -0700
commitbecfaeb778a3c8ba241e2155b998d6b27dcfad0c (patch)
tree97ca02178660fe958026a707905eac1c5ebd188d /csc/strings-test.csc
parentFix an issue with how the linker combined files. (diff)
downloadchromatopelma-becfaeb778a3c8ba241e2155b998d6b27dcfad0c.tar.zst
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.
Diffstat (limited to 'csc/strings-test.csc')
-rw-r--r--csc/strings-test.csc118
1 files changed, 60 insertions, 58 deletions
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 " " ")))))