diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-18 16:57:24 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-18 16:57:24 +0200 |
commit | c80020d23599a9ea7b60f83449dbb93762ca9770 (patch) | |
tree | 259d721f962783e4a51691b1034708f3e305eb20 /tests/conditionals.bad | |
parent | 649b378bb01a6964b9deec4d0fe57aeae1e5cb9e (diff) | |
download | bdl-c80020d23599a9ea7b60f83449dbb93762ca9770.tar.gz bdl-c80020d23599a9ea7b60f83449dbb93762ca9770.zip |
Add parsing support for basic conditionals and blocks
Diffstat (limited to 'tests/conditionals.bad')
-rw-r--r-- | tests/conditionals.bad | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/conditionals.bad b/tests/conditionals.bad new file mode 100644 index 0000000..45e1bd2 --- /dev/null +++ b/tests/conditionals.bad | |||
@@ -0,0 +1,19 @@ | |||
1 | ; Basic if expressions. | ||
2 | if true "hello" | ||
3 | |||
4 | ; These can produce values and the result bound to a name. | ||
5 | let a = if (2 + 2 >= 4) 42 | ||
6 | |||
7 | ; We support a single if expression. | ||
8 | let b = if 0xff == 255 "hello" else "world" | ||
9 | |||
10 | ; ... but these can compound on each other | ||
11 | if 1 < 2 6 | ||
12 | else if 1 > 2 7 | ||
13 | else 8 | ||
14 | |||
15 | ; A block is an expression, and if raise the scope level regardless if a block | ||
16 | ; is used or not. | ||
17 | if true != false { | ||
18 | let a = "yo" | ||
19 | } | ||