有没有办法通过Dr Racket / racket失败的测试用例消息获得更好的格式?

时间:2013-12-02 18:29:25

标签: racket

当我在Dr. Racket或命令行中运行测试时,失败的测试总是在一行上。

例如,

(bad (interp-t-prog (list '(class posn extends object ((x : num) (y : num)) (mdist : num -> num (+ (get this x) (get this y))) (addDist : posn -> num (+ (send arg mdist 0) (send this mdist 0)))) '(class posn3D extends posn ((z : num)) (mdist : num -> num (+ (get this z) (super mdist arg))))) `this) -1 "no type" "at line 96")

除了手动输入空格外,有没有办法让消息格式化得更好?

1 个答案:

答案 0 :(得分:2)

您的代码或Racket库是否产生错误?

pretty-print会帮助你吗?

#lang racket
(pretty-print
 '(bad (interp-t-prog (list '(class posn extends object ((x : num) (y : num)) (mdist : num -> num (+ (get this x) (get this y))) (addDist : posn -> num (+ (send arg mdist 0) (send this mdist 0)))) '(class posn3D extends posn ((z : num)) (mdist : num -> num (+ (get this z) (super mdist arg))))) `this) -1 "no type" "at line 96"))

=>

'(bad
  (interp-t-prog
   (list
    '(class posn
       extends
       object
       ((x : num) (y : num))
       (mdist : num -> num (+ (get this x) (get this y)))
       (addDist : posn -> num (+ (send arg mdist 0) (send this mdist 0))))
    '(class posn3D
       extends
       posn
       ((z : num))
       (mdist : num -> num (+ (get this z) (super mdist arg)))))
   `this)
  -1
  "no type"
  "at line 96")