Advertisement
dgulczynski

testy

May 13th, 2018
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.65 KB | None | 0 0
  1.  
  2. (define (test)
  3.   (define (test-aux xs ys)
  4.     (cond [(null? xs) #t]
  5.           [(= (calc (car xs)) (car ys)) (test-aux (cdr xs) (cdr ys))]
  6.           [else (fprintf (current-output-port)
  7.                          "Fail: ~a was evaluated to ~s instead of ~v.\n"
  8.                          (car xs) (calc (car xs)) (car ys))
  9.                 (and (test-aux (cdr xs) (cdr ys)) #f)]))
  10.   (let ((tests (list "1-2" "1/2" "1/2/3*3*2" "1-2-3-4" "1/2/3/4" "0-1+2/3"))
  11.         (answers (list -1 0.5 1 (calc "((1-2)-3)-4") (calc "((1/2)/3)/4") (calc "0+2/3-1"))))
  12.     (and (test-aux tests answers)
  13.          (display "All tests passed succesfully.\n")
  14.          #t)))
  15. (test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement