Recently Written · git

forthlisp

Scheme on a from-scratch Forth on from-scratch machine code: core (host Lisp, Scheme in Forth, R7RS harness)

git clone https://github.com/equwal/forthlisp

Log | Files | Refs


tests/r7rs/shim.scm (1070 bytes)

1 ; shim.scm -- maps the (chibi test) forms onto the chip Scheme. One form per line.
2 ; test and test-assert are procedures here: they evaluate their arguments like the macros do,
3 ; then print <<pass>> or <<fail VALUE>> for host.lisp to count.
4 (define (test-begin . o) #t)
5 (define (test-end . o) #t)
6 (define (%report ok got) (if ok (display "<<pass>>") (begin (display "<<fail ") (write got) (display ">>"))))
7 (define (test . args) (let ((expected (if (= (length args) 3) (cadr args) (car args))) (got (if (= (length args) 3) (caddr args) (cadr args)))) (%report (equal? expected got) got)))
8 (define (test-assert . args) (let ((got (car (reverse args)))) (%report (if got #t #f) got)))
9 (define-syntax test-error (syntax-rules () ((_ e) (%report (guard (c (#t #t)) e #f) 'no-error)) ((_ n e) (%report (guard (c (#t #t)) e #f) 'no-error))))
10 (define-syntax test-values (syntax-rules () ((_ x e) (test (call-with-values (lambda () x) list) (call-with-values (lambda () e) list))) ((_ n x e) (test (call-with-values (lambda () x) list) (call-with-values (lambda () e) list)))))