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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
;; -*-theme-d-*-
;; Copyright (C) 2014 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.
(define-interface (tests numerical-test-env)
(import (standard-library core)
(standard-library math))
(declare-method do-report-test
(:simple-proc (<object> <number> <number>) <none> nonpure))
(declare-method do-report-boolean-test
(:simple-proc (<object> <boolean> <boolean>) <none> nonpure))
(declare-method do-report-result
(:simple-proc (<object> <object>) <none> nonpure))
(define-syntax report-test
(syntax-rules ()
((_ test nr-correct)
(do-report-test (quote test) test nr-correct))))
(define-syntax report-boolean-test
(syntax-rules ()
((_ test b-correct)
(do-report-boolean-test (quote test) test b-correct))))
(define-syntax report-result
(syntax-rules ()
((_ expr)
(do-report-result (quote expr) expr))))
(define-syntax report-exception
(syntax-rules ()
((_ expr desired-kind)
(begin
(console-display-line (quote expr))
(guard-without-result
(exc
((rte-exception? exc)
(let ((s-kind (get-rte-exception-kind (cast <condition> exc))))
(console-display "exception ")
(console-display s-kind)
(console-display " ")
(if (equal? s-kind desired-kind)
(console-display-line "OK")
(console-display-line "FAIL"))))
(else
(console-display-line "wrong exception FAIL")))
expr
(console-display-line "no exception FAIL")))))))
|