RosettaCodeData/Task/S-Expressions/Common-Lisp/s-expressions-2.lisp
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

16 lines
676 B
Common Lisp

;;A list of unit tests. Each test is a cons in which the car (left side) contains the
;;test string and the cdr (right side) the expected result of reading the S-Exp.
(setf unit-tests
(list
(cons "[]" NIL)
(cons "[a b c]" '(a b c))
(cons "[\"abc\" \"def\"]" '("abc" "def"))
(cons "[1 2 [3 4 [5]]]" '(1 2 (3 4 (5))))
(cons "[\"(\" 1 2 \")\"]" '("(" 1 2 ")"))
(cons "[4/8 3/6 2/4]" '(1/2 1/2 1/2))
(cons "[reduce #'+ '[1 2 3]]" '(reduce #'+ '(1 2 3)))))
(defun run-tests ()
(dolist (test unit-tests)
(format t "String: ~23s Expected: ~23s Actual: ~s~%"
(car test) (cdr test) (read-from-string (car test)))))