sasagawa888 / eisl

ISLisp interpreter/compiler
Other
272 stars 22 forks source link

Added $TEST-ASSERT and refactored $TEST #260

Closed gtnoble closed 1 year ago

gtnoble commented 1 year ago

I created $TEST-ASSERT to give a macro that provides a function similar to "assert" in other languages. This macro evaluates both forms before comparing them. The tests in verify/all.sh pass.

I refactored $TEST to use $TEST-EQUAL.

> (import "test")
T
> ($test (+ 1 2) 3)
T
> ($test (+ 1 2) 4)
(+ 1 2) is bad. correct is 4 but got 3 
T
> ($test (+ 1 2) (+ 2 2))
(+ 1 2) is bad. correct is (+ 2 2) but got 3 
T
> ($test (+ 1 2) (+ 2 1))
(+ 1 2) is bad. correct is (+ 2 1) but got 3 
T
> ($test (list 1 2) (1 2))
T
> ($test-assert (+ 1 2) 3)
T
> ($test-assert (+ 1 2) 4)
(+ 1 2) is bad. correct is 4 but got 3 
T
> ($test-assert (+ 1 2) (+ 2 2))
(+ 1 2) is bad. correct is 4 but got 3 
T
> ($test-assert (+ 1 2) (+ 2 1))
T
> ($test-assert (list 1 2) (1 2))
Unbound function at EVAL 1

I cleaned up the documentation to make it sound more natural.

sasagawa888 commented 1 year ago

Thank you.