测试函数

最后更新于:2022-04-02 02:06:07

[TOC] ## 测试原则 当需要对值进行比较时,使用`equa?`进行测试。 ## 实例 ``` (define (add x y) (+ x y)) (define (test-add func-res hope-res) (cond [(equal? hope-res func-res) true] [else (error 'test-add "run is error func result is " func-res " expected is " hope-res)])) (test-add (add 1 2) 3) ;#true (test-add (add 1 2) 4) ;test-add: run is error func result is 3 expected is 4 ``` equal? 可以对任何类型类型进行比较
';