aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2026-03-03 01:09:48 -0500
committerGravatar Peter McGoron 2026-03-03 01:09:48 -0500
commitde85328c5a0e6047e3d8780c5642d14ce3272716 (patch)
tree0cf2a93fe7bce84e407d21487ded20637b0c4e1e /tests
parentsrfi-229 support (diff)
preparing for CHICKEN 6
Diffstat (limited to '')
-rw-r--r--tests/run.scm78
1 files changed, 67 insertions, 11 deletions
diff --git a/tests/run.scm b/tests/run.scm
index f965ba3..41269d8 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -22,7 +22,15 @@
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|#
-(import r7rs test (chicken condition) (chicken gc) (srfi 259 extensions) (srfi 229))
+(import test
+ (chicken condition)
+ (chicken gc)
+ (extensions srfi 259)
+ (srfi 229))
+
+(cond-expand
+ (chicken-5 (import r7rs))
+ (else))
(test-begin "SRFI 259")
@@ -34,66 +42,99 @@
(tagged (tag-foo 'bar (lambda (x)
(set! var (+ var x))
var))))
+ (gc #t)
(test-assert "tag-foo is tag-foo?" (tag-foo? tagged))
+ (gc #t)
(test "get-tag-foo returns tagged value" 'bar (get-tag-foo tagged))
+ (gc #t)
(test "var is previous value" 100 var)
+ (gc #t)
(test "tagged procedure is callable" 110 (tagged 10))
+ (gc #t)
(test "var has changed" 110 var)
+ (gc #t)
(test-assert "not tag-baz?" (not (tag-baz? tagged)))
+ (gc #t)
(test "get-tag-baz raises an exception"
'assertion
(condition-case (begin (get-tag-baz tagged) 'success)
((exn assertion) 'assertion)
(exn () 'error)))
+ (gc #t)
(test-group "tagged again"
(let ((tagged-again (tag-foo 'quux tagged)))
+ (gc #t)
(test-assert "tagging again retains tag-foo?" (tag-foo? tagged-again))
+ (gc #t)
(test "tagging again sets new value" 'quux (get-tag-foo tagged-again))
- (gc #f)
+ (gc #t)
(test "tagging again retains old value in previous procedure" 'bar (get-tag-foo tagged))
+ (gc #t)
(test-assert "the procedures not eqv?" (not (eqv? tagged tagged-again)))
+ (gc #t)
(test "tagging again returns a procedure" 150 (tagged 40))
- (test "var has changed" 150 var)))
+ (gc #t)
+ (test "var has changed" 150 var)
+ (gc #t)))
(test-group "tagged baz"
(let ((tagged-baz (tag-baz 'corge tagged)))
(test-assert "tag-baz?" (tag-baz? tagged-baz))
+ (gc #t)
(test-assert "tag-baz and tag-foo?" (tag-foo? tagged-baz))
+ (gc #t)
(test "retains get-tag-foo" 'bar (get-tag-foo tagged-baz))
+ (gc #t)
(test "retains get-tag-baz" 'corge (get-tag-baz tagged-baz))
- (test-assert "previous procedure is not tag-baz?" (not (tag-baz? tagged)))))))
+ (gc #t)
+ (test-assert "previous procedure is not tag-baz?" (not (tag-baz? tagged)))
+ (gc #t)))))
(test-group "tagging imported procedures"
(let* ((tagged (tag-foo 'foo +))
(tagged (tag-baz 'baz tagged)))
(test-assert "not tag-foo?" (not (tag-foo? +)))
+ (gc #t)
(test-assert "not tag-baz?" (not (tag-baz? +)))
+ (gc #t)
(test-assert "tag-foo?" (tag-foo? tagged))
+ (gc #t)
(test-assert "tag-baz?" (tag-baz? tagged))
+ (gc #t)
(test "operationally the same procedure?"
(+ 50 50)
(tagged 50 50))
+ (gc #t)
(test "get-tag-foo" 'foo (get-tag-foo tagged))
- (test "get-tag-baz" 'baz (get-tag-baz tagged))))
+ (gc #t)
+ (test "get-tag-baz" 'baz (get-tag-baz tagged))
+ (gc #t)))
(define-syntax raises-type-error
(syntax-rules ()
((raises-type-error name expr)
- (test name
- 'type
- (condition-case (begin expr 'success)
- ((exn type) 'type)
- (var () (display (condition->list var)) 'error))))))
+ (begin
+ (test name
+ 'type
+ (condition-case (begin expr 'success)
+ ((exn type) 'type)
+ (var () (display (condition->list var)) 'error)))
+ (gc #t)))))
(test-group "predicates on other objects"
(test-assert "integers are not tagged" (not (tag-foo? 0)))
+ (gc #t)
(raises-type-error "integers are not tagged" (tag-foo 'data 0))
(test-assert "strings are not tagged" (not (tag-foo? "hello")))
+ (gc #t)
(raises-type-error "strings are not tagged" (tag-foo 'data "hello"))
(test-assert "bytevectors are not tagged" (not (tag-foo? #u8(1 2 3 4))))
+ (gc #t)
(raises-type-error "bytevectors are not tagged" (tag-foo 'data #u8(1 2 3 4)))
(test-assert "vectors are not tagged" (not (tag-foo? #(call/cc))))
+ (gc #t)
(raises-type-error "vectors are not tagged" (tag-foo 'data #(call/cc)))
(test-assert "lists are not tagged" (not (tag-foo? '(1 2 3 4))))
+ (gc #t)
(raises-type-error "lists are not tagged" (tag-foo 'data '(1 2 3 4))))
(test-group "define-procedure-tag is a define form"
@@ -104,11 +145,17 @@
(define-procedure-tag tag-pure tag-pure? get-tag-pure)
(define tagged-square (tag-pure #t tagged-square))
(test-assert "square is tag-order?" (tag-order? tagged-square))
+ (gc #t)
(test-assert "square is tag-pure?" (tag-pure? tagged-square))
+ (gc #t)
(test "square order" 2 (get-tag-order tagged-square))
+ (gc #t)
(test-assert "square pure" (get-tag-pure tagged-square))
+ (gc #t)
(test-assert "is a procedure?" (procedure? tagged-square))
- (test "square value" (tagged-square 10) (square 10))))
+ (gc #t)
+ (test "square value" (tagged-square 10) (square 10))
+ (gc #t)))
(test-end "SRFI 259")
@@ -122,15 +169,24 @@
x)
(test "no tag" 10 (try-this 10))
+(gc #t)
(define new-try-this (tag-foo 10 try-this))
(test "with tag-foo" 20 (new-try-this 10))
+(gc #t)
+
(test "does not affect the one with no tag" 10 (try-this 10))
+(gc #t)
(define new-new-try-this (tag-baz 20 new-try-this))
(test "with tag-baz" 40 (new-new-try-this 10))
+(gc #t)
+
(test "does not affect the one with tag-foo" 20 (new-try-this 10))
+(gc #t)
+
(test "does not affect the one with no tag" 10 (try-this 10))
+(gc #t)
(test-end "SRFI 259 extensions")