aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-10 12:11:45 +0200
committerBad Diode <bd@badd10de.dev>2021-10-10 12:11:45 +0200
commit4673fde605090320fbab227e56bb085eec97362a (patch)
tree5d510484d5543b4b11fd62b42a4b1e14672ff2cd /examples
parentc2bfb5368e603d686190fdc9f3ddbafbda075a9c (diff)
downloadbdl-4673fde605090320fbab227e56bb085eec97362a.tar.gz
bdl-4673fde605090320fbab227e56bb085eec97362a.zip
Add boolean primitives and more (better) tests
Diffstat (limited to 'examples')
-rw-r--r--examples/arithmetic.bdl34
-rw-r--r--examples/booleans.bdl45
2 files changed, 62 insertions, 17 deletions
diff --git a/examples/arithmetic.bdl b/examples/arithmetic.bdl
index 5e102e9..83404e2 100644
--- a/examples/arithmetic.bdl
+++ b/examples/arithmetic.bdl
@@ -1,22 +1,22 @@
1; 1;;
2; Basic arithmetic operations 2;; Basic arithmetic operations.
3; 3;;
4 4
5; Addition 5;; Addition.
6(+ 10 100) 6(print "(+ 10 100) -> ") (+ 10 100)
7(+ 1 -2 3 4) 7(print "(+ 1 -2 3 4) -> ") (+ 1 -2 3 4)
8 8
9; Substraction 9;; Substraction.
10(- 100 75) 10(print "(- 100 75) -> ") (- 100 75)
11(- 10 20 30) 11(print "(- 10 20 30) -> ") (- 10 20 30)
12 12
13; Multiplication 13;; Multiplication.
14(* 10 7) 14(print "(* 10 7) -> ") (* 10 7)
15(* -1 66) 15(print "(* -1 66) -> ") (* -1 66)
16 16
17; Division 17;; Division.
18(/ 45 5) 18(print "(/ 45 5) -> ") (/ 45 5)
19(/ 10 5 2) 19(print "(/ 10 5 2) -> ") (/ 10 5 2)
20 20
21; Nesting operations. 21;; Nesting operations.
22(* 20 (+ 100 (- 50 30) (/ 300 3)) 10) 22(print "(* 20 (+ 100 (- 50 30) (/ 300 3)) 10) -> ") (* 20 (+ 100 (- 50 30) (/ 300 3)) 10)
diff --git a/examples/booleans.bdl b/examples/booleans.bdl
new file mode 100644
index 0000000..d248bf8
--- /dev/null
+++ b/examples/booleans.bdl
@@ -0,0 +1,45 @@
1;;
2;; Boolean primitives.
3;;
4
5;; Boolean test.
6(print "(boolean? true) -> ") (boolean? true)
7(print "(boolean? false) -> ") (boolean? false)
8(print "(boolean? 1) -> ") (boolean? 1)
9(print "(boolean? 5) -> ") (boolean? 5)
10(print "(boolean? \"string\") -> ") (boolean? "string")
11(print "(boolean? (+ 1 2 3)) -> ") (boolean? (+ 1 2 3))
12(print "(boolean? (not 1)) -> ") (boolean? (not 1))
13
14;; Not.
15(print "(not true) -> ") (not true)
16(print "(not false) -> ") (not false)
17(print "(not (not true)) -> ") (not (not true))
18(print "(not (not false)) -> ") (not (not false))
19(print "(not 1) -> ") (not 1)
20(print "(not (not 1)) -> ") (not (not 1))
21(print "(not \"string\") -> ") (not "string")
22(print "(not (not \"string\")) -> ") (not (not "string"))
23
24;; And.
25(print "(and 1 \"string\" 4 true) -> ") (and 1 "string" 4 true)
26(print "(and true true true) -> ") (and true true true)
27(print "(and (+ 1 2 3)) -> ") (and (+ 1 2 3))
28(print "(and false false false) -> ") (and false false false)
29(print "(and true false false) -> ") (and true false false)
30(print "(and false true false) -> ") (and false true false)
31(print "(and false true true) -> ") (and false true true)
32(print "(and (not false) true true) -> ") (and (not false) true true)
33
34;; Or.
35(print "(or 1 \"string\" 4 true) -> ") (or 1 "string" 4 true)
36(print "(or false 1) -> ") (or false 1)
37(print "(or false \"string\") -> ") (or false "string")
38(print "(or false) -> ") (or false)
39(print "(or true true true) -> ") (or true true true)
40(print "(or false false false) -> ") (or false false false)
41(print "(or true false false) -> ") (or true false false)
42(print "(or false true false) -> ") (or false true false)
43(print "(or false true true) -> ") (or false true true)
44(print "(or (not false) true true) -> ") (or (not false) true true)
45(print "(or (not true) false) -> ") (or (not true) false)