Skip to content

Commit cf2e1d9

Browse files
count crashes as well as mismatches
1 parent 79ce0df commit cf2e1d9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

autotest.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
TESTS = r"""
88
9-
(defvar ers 0)
9+
(defvar errors 0)
10+
(defvar crashes 0)
1011
11-
(defun aeq (tst x y) (unless (or (and (floatp x) (floatp y) (< (abs (- x y)) 0.000005)) (equal x y)) (incf ers) (format t "~a=~a/~a~%" tst x y)))
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)))
1213
1314
#| Symbols |#
1415
@@ -782,15 +783,18 @@
782783
783784
#| errors |#
784785
785-
(aeq 'errors 0 ers)
786+
(format t "~%~a errors, ~a crashes~%" errors crashes)
787+
786788
"""
787789

788790

789791
def talk(string, port, ttw=0.1):
790792
port.reset_output_buffer()
791793
port.write(string.encode())
792794
time.sleep(ttw)
793-
sys.stdout.write(port.read(port.in_waiting).decode().replace("\r\n", "\n"))
795+
text = port.read(port.in_waiting).decode().replace("\r\n", "\n")
796+
sys.stdout.write(text)
797+
return text
794798

795799

796800
def test():
@@ -802,7 +806,9 @@ def test():
802806

803807
for line in TESTS.split("\n"):
804808
if line and line.startswith("("):
805-
talk(line, port)
809+
text = talk(line, port)
810+
if "Error:" in text:
811+
talk("(incf crashes)", port)
806812

807813
test()
808814

0 commit comments

Comments
 (0)