~tim/scheme-vm

ref: 3c0fc6fa79193278089891e19d63a0f0ddff22c7 scheme-vm/lib/assert.scm -rw-r--r-- 1.1 KiB
3c0fc6faTim Morgan Remove halt option from compile method 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(define-library (assert)
  (import (only (scheme base) begin define-syntax = eq? eqv? equal? if newline not quote write-string))
  (export assert)
  (begin
    (define-syntax assert
      (syntax-rules (eq? eqv? equal?)
        ((assert (= expected actual))
         (assert (= expected actual) expected actual))
        ((assert (eq? expected actual))
         (assert (eq? expected actual) expected actual))
        ((assert (eqv? expected actual))
         (assert (eqv? expected actual) expected actual))
        ((assert (equal? expected actual))
         (assert (equal? expected actual) expected actual))
        ((assert expr)
         (assert expr (quote (not #f)) expr))
        ((assert expr expected actual)
         (if (not expr)
             (begin
               (write-string "(assert ")
               (write-string (quote expr))
               (write-string ") failed:")
               (newline)
               (write-string "  expected: ")
               (write-string expected)
               (newline)
               (write-string "  actual:   ")
               (write-string actual)
               (newline))))))))