-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.rkt
41 lines (31 loc) · 1.1 KB
/
common.rkt
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
#lang racket
;; ===================================================================================================
;; this file provides a debugging routine and -- from (modul test ..) functions/syntax for testing,
;; including json testing in Xternal/
;; SERVICES
(provide
debug)
(module+ test
(provide
;; parameter: the function to be tested
testing
;; SYNTAX (run-testing x ... w msg) runs (testing)
;; on x ..., compares its output with w; reports msg for failures
run-testing))
;; ===================================================================================================
;; IMPLEMENTATION
;; (define *debug (open-output-file "/dev/tty" #:exists 'append))
(define *debug (current-error-port))
(define (debug x)
(displayln x *debug)
x)
(module+ test
(require rackunit)
(define testing
(make-parameter
;; String -> String
(lambda x (error 'testing "nothing to test"))))
(define-syntax-rule
(run-testing x ... expected msg)
;; --- the ordering matters because x ... might be a mutable object
(check-equal? ((testing) x ...) expected msg)))