summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-21 12:56:30 +0100
committerubq323 <ubq323@ubq323.website>2024-06-21 12:56:30 +0100
commit21994864559386f1d11c001d6d27714cbf624a15 (patch)
treeb9a5e76bdc8be9a41970cd6620aab7a3637b7e6a /tests
parent671645c370498955eb101695bd9099bf4caf5aea (diff)
add tests, and make dumping disasm optional
Diffstat (limited to 'tests')
-rw-r--r--tests/compile_error.bþ1
-rw-r--r--tests/compile_error.out1
-rw-r--r--tests/fizzbuzz.bþ10
-rw-r--r--tests/fizzbuzz.out30
-rw-r--r--tests/four.bþ1
-rw-r--r--tests/four.out1
-rw-r--r--tests/vars.bþ9
-rw-r--r--tests/vars.out5
8 files changed, 58 insertions, 0 deletions
diff --git a/tests/compile_error.bþ b/tests/compile_error.bþ
new file mode 100644
index 0000000..b151c2f
--- /dev/null
+++ b/tests/compile_error.bþ
@@ -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þ b/tests/fizzbuzz.bþ
new file mode 100644
index 0000000..e70c2c1
--- /dev/null
+++ b/tests/fizzbuzz.bþ
@@ -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þ b/tests/four.bþ
new file mode 100644
index 0000000..8804fe4
--- /dev/null
+++ b/tests/four.bþ
@@ -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þ b/tests/vars.bþ
new file mode 100644
index 0000000..7799acf
--- /dev/null
+++ b/tests/vars.bþ
@@ -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