diff --git a/A1/infix-ae.rkt b/A1/infix-ae.rkt index 19d466a..d25d903 100644 --- a/A1/infix-ae.rkt +++ b/A1/infix-ae.rkt @@ -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 \ No newline at end of file