33 lines
665 B
Scheme
33 lines
665 B
Scheme
|
(use-modules (d-)
|
||
|
(rnrs base))
|
||
|
|
||
|
(define-syntax-rule (define-unit-test (test-name body ...))
|
||
|
(let () body ...))
|
||
|
|
||
|
(define-syntax-rule (define-test module-name tests ...)
|
||
|
(begin (define-unit-test tests) ...))
|
||
|
|
||
|
(define-test ~>
|
||
|
(unwrapped
|
||
|
(define value (~> 1 1+ 1+))
|
||
|
(assert (= value 3)))
|
||
|
(wrapped
|
||
|
(define value (~> 1 (/ 2) (/ 2)))
|
||
|
(assert (= value 1/4))))
|
||
|
|
||
|
(define-test ~>>
|
||
|
(unwrapped
|
||
|
(define value (~>> 1 1+ 1+))
|
||
|
(assert (= value 3)))
|
||
|
(wrapped
|
||
|
(define value (~>> 1 (/ 2) (/ 2)))
|
||
|
(assert (= value 1))))
|
||
|
|
||
|
(define-test partial
|
||
|
(test
|
||
|
(define value (partial / 2))
|
||
|
(assert (= (value 4) 1/2))
|
||
|
(assert (= (value 1) 2))))
|
||
|
|
||
|
|