From 21994864559386f1d11c001d6d27714cbf624a15 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 21 Jun 2024 12:56:30 +0100 Subject: add tests, and make dumping disasm optional --- "tests/compile_error.b\303\276" | 1 + tests/compile_error.out | 1 + "tests/fizzbuzz.b\303\276" | 10 ++++++++++ tests/fizzbuzz.out | 30 ++++++++++++++++++++++++++++++ "tests/four.b\303\276" | 1 + tests/four.out | 1 + "tests/vars.b\303\276" | 9 +++++++++ tests/vars.out | 5 +++++ 8 files changed, 58 insertions(+) create mode 100644 "tests/compile_error.b\303\276" create mode 100644 tests/compile_error.out create mode 100644 "tests/fizzbuzz.b\303\276" create mode 100644 tests/fizzbuzz.out create mode 100644 "tests/four.b\303\276" create mode 100644 tests/four.out create mode 100644 "tests/vars.b\303\276" create mode 100644 tests/vars.out (limited to 'tests') diff --git "a/tests/compile_error.b\303\276" "b/tests/compile_error.b\303\276" new file mode 100644 index 0000000..b151c2f --- /dev/null +++ "b/tests/compile_error.b\303\276" @@ -0,0 +1 @@ +(while) diff --git a/tests/compile_error.out b/tests/compile_error.out new file mode 100644 index 0000000..b7b8184 --- /dev/null +++ b/tests/compile_error.out @@ -0,0 +1 @@ +while requires at least 2 arguments diff --git "a/tests/fizzbuzz.b\303\276" "b/tests/fizzbuzz.b\303\276" new file mode 100644 index 0000000..e70c2c1 --- /dev/null +++ "b/tests/fizzbuzz.b\303\276" @@ -0,0 +1,10 @@ +(do + (set n 1) + (while (< n 30) + (print + (if (= 0 (% n 5)) + (if (= 0 (% n 3)) "fizzbuzz" "buzz") + (if (= 0 (% n 3)) "fizz" n))) + (set n (+ n 1)))) + + diff --git a/tests/fizzbuzz.out b/tests/fizzbuzz.out new file mode 100644 index 0000000..51ff50b --- /dev/null +++ b/tests/fizzbuzz.out @@ -0,0 +1,30 @@ +1 +2 +fizz +4 +buzz +fizz +7 +8 +fizz +buzz +11 +fizz +13 +14 +fizzbuzz +16 +17 +fizz +19 +buzz +fizz +22 +23 +fizz +buzz +26 +fizz +28 +29 +nil diff --git "a/tests/four.b\303\276" "b/tests/four.b\303\276" new file mode 100644 index 0000000..8804fe4 --- /dev/null +++ "b/tests/four.b\303\276" @@ -0,0 +1 @@ +(+ 2 2) diff --git a/tests/four.out b/tests/four.out new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/tests/four.out @@ -0,0 +1 @@ +4 diff --git "a/tests/vars.b\303\276" "b/tests/vars.b\303\276" new file mode 100644 index 0000000..7799acf --- /dev/null +++ "b/tests/vars.b\303\276" @@ -0,0 +1,9 @@ +(do + (set a 5) + (set b 10) + (set thethe 1234) + (print (+ a b)) + (print (- thethe a)) + (print (+ (set a 90) b)) + (print a) + nil) diff --git a/tests/vars.out b/tests/vars.out new file mode 100644 index 0000000..bef4ee4 --- /dev/null +++ b/tests/vars.out @@ -0,0 +1,5 @@ +15 +1229 +100 +90 +nil -- cgit v1.2.3