6
6
7
7
TESTS = r"""
8
8
9
- (defvar errors 0 )
9
+ (defvar errors nil )
10
10
(defvar crashes 0)
11
11
12
- (defun aeq (testname x y) (unless (or (and (floatp x) (floatp y) (< (abs (- x y)) 0.000005)) (equal x y)) (incf errors) (format t "~a=~a/~a~%" testname x y)))
12
+ (defun aeq (testname x y)
13
+ (unless (or (and (floatp x)
14
+ (floatp y)
15
+ (< (abs (- x y)) 0.000005))
16
+ (equal x y))
17
+ (let (b (assoc testname errors))
18
+ (if b (incf (cdr b))
19
+ (push (cons testname 1) errors)))
20
+ (format t "~a fail: expected ~a, got ~a~%" testname x y)))
13
21
14
22
#| Symbols |#
15
23
23
31
(aeq 'let 88 (let ((abcdefgh 88)) abcdefgh))
24
32
(aeq 'let 99 (let ((abcdefghi 99)) abcdefghi))
25
33
(aeq 'let 1010 (let ((abcdefghij 1010)) abcdefghij))
26
- (aeq 'let "ab9" (princ-to-string 'ab9))
27
- (aeq 'let t (eq 'me 'me))
28
- (aeq 'let t (eq 'fishcake 'fishcake))
29
- (aeq 'let nil (eq 'fishcak 'fishca))
34
+ (aeq 'princ-to-string "ab9" (princ-to-string 'ab9))
35
+ (aeq 'eq t (eq 'me 'me))
36
+ (aeq 'eq t (eq 'fishcake 'fishcake))
37
+ (aeq 'eq nil (eq 'fishcak 'fishca))
30
38
31
39
#| Arithmetic |#
32
40
783
791
784
792
#| errors |#
785
793
786
- (format t "~%~a errors, ~a crashes~% " errors crashes)
794
+ (format t "~%Failing tests:~%~{~a~%~}~%~a tests crashed. " errors crashes)
787
795
788
796
"""
789
797
790
798
791
- def talk (string , port , ttw = 0.1 ):
799
+ def talk (string : str , port : serial . Serial , ttw : float = 0.1 ):
792
800
port .reset_output_buffer ()
793
801
port .write (string .encode ())
794
802
time .sleep (ttw )
@@ -810,5 +818,5 @@ def test():
810
818
if "Error:" in text or "Error in" in text :
811
819
talk ("(incf crashes)" , port )
812
820
813
- test ()
814
821
822
+ test ()
0 commit comments