diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-19 08:43:17 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-19 08:51:00 +0200 |
commit | eed58fa9d2bccf9df9128e6eff08fcd08b6fa95e (patch) | |
tree | 67ac983d04880a6ac80d8b0cb71e05ebb0cc5ea0 /tests | |
parent | faf69726d4fc619bc55a2c1105bd542673cce342 (diff) | |
download | bdl-eed58fa9d2bccf9df9128e6eff08fcd08b6fa95e.tar.gz bdl-eed58fa9d2bccf9df9128e6eff08fcd08b6fa95e.zip |
Change a few syntax constructs for consistency
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conditionals.bad | 14 | ||||
-rw-r--r-- | tests/loops.bad | 18 |
2 files changed, 19 insertions, 13 deletions
diff --git a/tests/conditionals.bad b/tests/conditionals.bad index 856ac8a..e1a456e 100644 --- a/tests/conditionals.bad +++ b/tests/conditionals.bad | |||
@@ -1,26 +1,26 @@ | |||
1 | ; Basic if expressions. | 1 | ; Basic if expressions. |
2 | if true "hello" | 2 | if (true) "hello" |
3 | 3 | ||
4 | ; These can produce values and the result bound to a name. | 4 | ; These can produce values and the result bound to a name. |
5 | let a = if (2 + 2 >= 4) 42 | 5 | let a = if (2 + 2 >= 4) 42 |
6 | 6 | ||
7 | ; We support a single if expression. | 7 | ; We support a single if expression. |
8 | let b = if 0xff == 255 "hello" else "world" | 8 | let b = if (0xff == 255) "hello" else "world" |
9 | 9 | ||
10 | ; ... but these can compound on each other | 10 | ; ... but these can compound on each other |
11 | if 1 < 2 6 | 11 | if (1 < 2) 6 |
12 | else if 1 > 2 7 | 12 | else if (1 > 2) 7 |
13 | else 8 | 13 | else 8 |
14 | 14 | ||
15 | ; A block is an expression, and if raise the scope level regardless if a block | 15 | ; A block is an expression, and if raise the scope level regardless if a block |
16 | ; is used or not. | 16 | ; is used or not. |
17 | if true != false { | 17 | if (true != false) { |
18 | let a = "yo" | 18 | let a = "yo" |
19 | } | 19 | } |
20 | 20 | ||
21 | ; Match cases should only apply to literal values, for example `case 1 + 2` | 21 | ; Match cases should only apply to literal values, for example `case 1 + 2` |
22 | ; isn't allowed. They should generally convert to a lookup table. | 22 | ; isn't allowed. They should generally convert to a lookup table. |
23 | match a = { | 23 | match (a) { |
24 | case 8 = "hello" | 24 | case 8 = "hello" |
25 | case 9 = "world" | 25 | case 9 = "world" |
26 | else = "what" | 26 | else = "what" |
@@ -37,7 +37,7 @@ enum flags { | |||
37 | let a:flags = flags.node_add | 37 | let a:flags = flags.node_add |
38 | 38 | ||
39 | ; No need to qualify enum fields inside match-case. | 39 | ; No need to qualify enum fields inside match-case. |
40 | match a = { | 40 | match (a) { |
41 | case node_add = "adding something..." | 41 | case node_add = "adding something..." |
42 | case node_add = "subbing something..." | 42 | case node_add = "subbing something..." |
43 | else = "default case" | 43 | else = "default case" |
diff --git a/tests/loops.bad b/tests/loops.bad index 5221844..45c9712 100644 --- a/tests/loops.bad +++ b/tests/loops.bad | |||
@@ -1,18 +1,24 @@ | |||
1 | ; The most basic loop is the while loop. | 1 | ; The most basic loop is the while loop. |
2 | while abc = "heelo" | 2 | while (abc) "heelo" |
3 | 3 | ||
4 | while 1 + 2 == 3 = { | 4 | while (1 + 2 == 3) { |
5 | "hello" | 5 | "hello" |
6 | } | 6 | } |
7 | 7 | ||
8 | while symbol = { | 8 | while (symbol) { |
9 | "hello" | 9 | "hello" |
10 | } | 10 | } |
11 | 11 | ||
12 | |||
13 | ; We could use some sugar for this. | 12 | ; We could use some sugar for this. |
14 | let i = 0 | 13 | let i = 0 |
15 | while i < 10 = { | 14 | while (i < 10) { |
16 | "hello" | 15 | "hello" |
17 | set i = i + 1 | 16 | ; --i |
18 | } | 17 | } |
18 | ; TODO: add post/pre increment tokens | ||
19 | ; TODO: add functions | ||
20 | ; TODO: add function calls | ||
21 | |||
22 | ; for let i = 1, 1 < 10, i++ { | ||
23 | |||
24 | ; } | ||