diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fizzbuzz.bth | 15 | ||||
-rw-r--r-- | tests/func1.bth | 5 | ||||
-rw-r--r-- | tests/func2.bth | 11 | ||||
-rw-r--r-- | tests/func3.bth | 17 | ||||
-rw-r--r-- | tests/func4.bth | 13 | ||||
-rw-r--r-- | tests/mandel.bth | 41 | ||||
-rw-r--r-- | tests/vars.bth | 17 | ||||
-rw-r--r-- | tests/vars3.bth | 11 | ||||
-rw-r--r-- | tests/vars4.bth | 13 |
9 files changed, 67 insertions, 76 deletions
diff --git a/tests/fizzbuzz.bth b/tests/fizzbuzz.bth index 82e80cf..42c1760 100644 --- a/tests/fizzbuzz.bth +++ b/tests/fizzbuzz.bth @@ -1,10 +1,9 @@ -(do - (set n 1) - (while (< n 30) - (puts - (if (= 0 (% n 5)) - (if (= 0 (% n 3)) "fizzbuzz" "buzz") - (if (= 0 (% n 3)) "fizz" n))) - (set n (+ n 1)))) +(set n 1) +(while (< n 30) + (puts + (if (= 0 (% n 5)) + (if (= 0 (% n 3)) "fizzbuzz" "buzz") + (if (= 0 (% n 3)) "fizz" n))) + (set n (+ n 1))) diff --git a/tests/func1.bth b/tests/func1.bth index c46e956..e55f23a 100644 --- a/tests/func1.bth +++ b/tests/func1.bth @@ -1,3 +1,2 @@ -(do - (set f (fn (_) 42)) - (f 0)) +(set f (fn (_) 42)) +(f 0) diff --git a/tests/func2.bth b/tests/func2.bth index fd16eda..14f0799 100644 --- a/tests/func2.bth +++ b/tests/func2.bth @@ -1,6 +1,5 @@ -(do - (set f1 (fn (a) (* a a))) - (set f2 (fn (a b) (+ a b))) - (puts (f1 6)) - (puts (f2 20 40)) - (f1 (f2 2 1))) +(set f1 (fn (a) (* a a))) +(set f2 (fn (a b) (+ a b))) +(puts (f1 6)) +(puts (f2 20 40)) +(f1 (f2 2 1)) diff --git a/tests/func3.bth b/tests/func3.bth index 2da8cc9..59392e1 100644 --- a/tests/func3.bth +++ b/tests/func3.bth @@ -1,9 +1,8 @@ -(do - (set f1 (fn (a b) (* a b))) - (set f2 (fn (x) - (set xx x) - (let (a 3 - g (fn (y) (+ y 7))) - (* (g a) (g xx))))) - (puts (f1 6 6)) - (f2 7)) +(set f1 (fn (a b) (* a b))) +(set f2 (fn (x) + (set xx x) + (let (a 3 + g (fn (y) (+ y 7))) + (* (g a) (g xx))))) +(puts (f1 6 6)) +(f2 7) diff --git a/tests/func4.bth b/tests/func4.bth index 7c04cf3..640c889 100644 --- a/tests/func4.bth +++ b/tests/func4.bth @@ -1,7 +1,6 @@ -(do - (set f1 (fn (x) (+ x 10))) - (set f2 (fn (x) (* x 10))) - (set g (fn (f x) (puts (f x)) (puts (f x)))) - (g f1 26) - (g f2 6) - nil) +(set f1 (fn (x) (+ x 10))) +(set f2 (fn (x) (* x 10))) +(set g (fn (f x) (puts (f x)) (puts (f x)))) +(g f1 26) +(g f2 6) +nil diff --git a/tests/mandel.bth b/tests/mandel.bth index ffe49c7..54a1b4d 100644 --- a/tests/mandel.bth +++ b/tests/mandel.bth @@ -1,21 +1,20 @@ -(do - (set pxy 0) - (while (< pxy 30) - (set cim (/ (- pxy 15) 15)) - (set pxx 0) - (while (< pxx 60) - (set cre (/ (- pxx 40) 20)) - (set i 0) - (set zim cim) - (set zre cre) - (while (< i 25) - (set nzre (+ cre (- (* zre zre) (* zim zim)))) - (set nzim (+ cim (* 2 (* zre zim)))) - (set zre nzre) - (set zim nzim) - (set mag (+ (* zre zre) (* zim zim))) - (set i (if (< mag 4) (+ i 1) 999))) - (print (if (< mag 4) "#" ".")) - (set pxx (+ pxx 1))) - (puts "") - (set pxy (+ pxy 1)))) +(set pxy 0) +(while (< pxy 30) + (set cim (/ (- pxy 15) 15)) + (set pxx 0) + (while (< pxx 60) + (set cre (/ (- pxx 40) 20)) + (set i 0) + (set zim cim) + (set zre cre) + (while (< i 25) + (set nzre (+ cre (- (* zre zre) (* zim zim)))) + (set nzim (+ cim (* 2 (* zre zim)))) + (set zre nzre) + (set zim nzim) + (set mag (+ (* zre zre) (* zim zim))) + (set i (if (< mag 4) (+ i 1) 999))) + (print (if (< mag 4) "#" ".")) + (set pxx (+ pxx 1))) + (puts "") + (set pxy (+ pxy 1))) diff --git a/tests/vars.bth b/tests/vars.bth index a524ae6..54555ad 100644 --- a/tests/vars.bth +++ b/tests/vars.bth @@ -1,9 +1,8 @@ -(do - (set a 5) - (set b 10) - (set thethe 1234) - (puts (+ a b)) - (puts (- thethe a)) - (puts (+ (set a 90) b)) - (puts a) - nil) +(set a 5) +(set b 10) +(set thethe 1234) +(puts (+ a b)) +(puts (- thethe a)) +(puts (+ (set a 90) b)) +(puts a) +nil diff --git a/tests/vars3.bth b/tests/vars3.bth index 19e82fa..0c1c0b4 100644 --- a/tests/vars3.bth +++ b/tests/vars3.bth @@ -1,6 +1,5 @@ -(do - (set x 1) - (set y 10) - (let (x 2) - (let (y 20) - (+ x y)))) +(set x 1) +(set y 10) +(let (x 2) + (let (y 20) + (+ x y))) diff --git a/tests/vars4.bth b/tests/vars4.bth index 20820e3..b4a2f25 100644 --- a/tests/vars4.bth +++ b/tests/vars4.bth @@ -1,8 +1,7 @@ -(do - (set x 100) +(set x 100) +(puts x) +(let (x 20) (puts x) - (let (x 20) - (puts x) - (set x 30) - (puts x)) - x) + (set x 30) + (puts x)) +x |