Organize tests

This commit is contained in:
Isaac Shoebottom 2025-01-14 14:12:58 -04:00
parent d8d1d840bb
commit 13022f03d0

View File

@ -53,13 +53,18 @@
(define (run sx)
(eval (parse-sx sx)))
(test (run `3) 3)
(test (run `{3 + 4}) 7)
(test (run `{{3 - 4} + 7}) 6)
(test (run `{8 * 9}) 72)
(test (run `{8 / 2}) 4)
(test (run `{-8 / 0}) -inf.0)
(test (run `{8 / {5 - 5}}) +inf.0)
(test (run `{1 / {1 / 0}}) 0.0)
;; Basic Parser tests
(test (run `3) 3) ; Evalutate number by itself
(test (run `{3 + 4}) 7) ; Evaluate two positive integers addition
(test (run `{{3 - 4} + 7}) 6) ; Evaluate subtraction and addition
(test (run `{8 * 9}) 72) ; Evaluate multiplication
(test (run `{8 / 2}) 4) ; Evaluate division
;; Divide by zero tests
(test (run `{-8 / 0}) -inf.0) ; Negative divide by zero
(test (run `{8 / {5 - 5}}) +inf.0) ; Positive divide by zero
(test (run `{1 / {1 / 0}}) 0.0) ; Divide by positive infinity
(test (run `{0 / 0}) +nan.0) ; Special 0/0 case
;; Parser Errors
(test/exn (run `{+ 1 1}) "parse") ; Parse error