aboutsummaryrefslogtreecommitdiffstats
path: root/csc/testing.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-01 19:35:19 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-01 19:35:19 -0700
commitacc561366f3fe6ec0377103f52ef0f7e923711c9 (patch)
treed7a19cfbad78a69ebea71b27302e708c0655863d /csc/testing.csc
parent99ce19a8053a93457885f32ec54c1c5b7c1961c1 (diff)
downloadchromatopelma-acc561366f3fe6ec0377103f52ef0f7e923711c9.tar.zst
Modify the project structure.
Now the lib directory contains what will eventually end up on the user's /usr/lib/csc. When I write make install, it will copy all of the .csc files from lib into the destination lib directory. This means I can start working on the standard library in lib/scheme.
Diffstat (limited to 'csc/testing.csc')
-rw-r--r--csc/testing.csc91
1 files changed, 0 insertions, 91 deletions
diff --git a/csc/testing.csc b/csc/testing.csc
deleted file mode 100644
index 68678ca..0000000
--- a/csc/testing.csc
+++ /dev/null
@@ -1,91 +0,0 @@
-(define-library (csc testing)
- (export
- assert
- assert-equal
- assert-raises
- test
- test-main)
- (import (scheme base)
- (only (scheme write)
- display
- write)
- (only (csc compare) diff))
- (begin
-
-
- (define *all-tests-succeeded* #t)
-
-
- (define (set-all-succeeded! val) (set! *all-tests-succeeded* val))
-
-
- (define-record-type <test-handle>
- (make-test-handle test-name)
- test-handle?
- (test-name test-name set-name!))
-
-
- (define-record-type <test-error>
- (make-test-error)
- test-error?)
-
-
- (define *test-error* (make-test-error))
-
-
- (define *test-handle* (make-test-handle "global"))
-
-
- (define (print . xs)
- (unless (null? xs)
- (let ((x (car xs)))
- (if (or (string? x)
- (symbol? x))
- (display x)
- (write x)))
- (apply print (cdr xs))))
-
-
- (define-syntax test
- (syntax-rules ()
- ((test name body body* ...)
- (begin
- (set-name! *test-handle* (symbol->string 'name))
- (print "=== RUN " 'name "\n")
- (guard (e ((test-error? e)
- (print "--- FAIL: " 'name "\n")
- (set-all-succeeded! #f)))
- body body* ...
- (print "--- PASS: " 'name "\n"))))))
-
-
- (define-syntax assert
- (syntax-rules ()
- ((assert expr)
- (unless expr
- (print (test-name *test-handle*) ": (assert " 'expr ") failed.\n")
- (raise *test-error*)))))
-
-
- (define-syntax assert-equal
- (syntax-rules ()
- ((assert-equal left right transformers ...)
- (let ((d (diff left right transformers ...)))
- (unless (string=? "" d)
- (print "Fatal:\n " 'left "\nis not equal to\n " 'right "\ndiff (-left +right):\n" d "\n")
- (raise *test-error*))))))
-
-
- (define-syntax assert-raises
- (syntax-rules ()
- ((assert-raises predicate body body* ...)
- (assert
- (guard (e ((predicate e) #t))
- body body* ...
- #f)))))
-
-
- (define (test-main)
- (if *all-tests-succeeded*
- (print "PASS\n")
- (print "FAIL\n")))))