diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-18 10:02:38 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-18 10:02:38 +0200 |
commit | 9c3837060d1089131b351761db97544db8738de3 (patch) | |
tree | c76087681b4a947dece76be90161c0a89918abd3 /tests | |
parent | f392b0818e651ece33cec091eac0639883a126ec (diff) | |
download | bdl-9c3837060d1089131b351761db97544db8738de3.tar.gz bdl-9c3837060d1089131b351761db97544db8738de3.zip |
Add struct literals
Diffstat (limited to 'tests')
-rw-r--r-- | tests/variables.bad | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/variables.bad b/tests/variables.bad index a6f9900..a653dc7 100644 --- a/tests/variables.bad +++ b/tests/variables.bad | |||
@@ -2,14 +2,12 @@ | |||
2 | ; inferred, but can also be manually specified. | 2 | ; inferred, but can also be manually specified. |
3 | let a | 3 | let a |
4 | let b: f64 | 4 | let b: f64 |
5 | let c = 10 | 5 | let c:u64 = 20 |
6 | let d:u64 = 20 | ||
7 | 6 | ||
8 | ; No infix '=', instead we use `set` to bind values. | 7 | ; No infix '=', instead we use `set` to bind values. |
9 | set a = "hello" | 8 | set a = "hello" |
10 | set b = 1.2 | 9 | set b = 1.2 |
11 | set c = 30 | 10 | set c = (1 + 2 - 3) |
12 | set d = (1 + 2 - 3) | ||
13 | 11 | ||
14 | ; Struct definitions. | 12 | ; Struct definitions. |
15 | struct vec { | 13 | struct vec { |
@@ -46,12 +44,12 @@ struct entity { | |||
46 | } | 44 | } |
47 | 45 | ||
48 | ; Symbols followed by curly braces output struct literals. | 46 | ; Symbols followed by curly braces output struct literals. |
49 | ; let particle = entity { | 47 | let particle = entity { |
50 | ; ; Two ways of initializing inner fields. | 48 | ; Two ways of initializing inner fields. |
51 | ; pos = { 1 2 } | 49 | pos = vec { x = 1 y = 2 } |
52 | ; attr.id = 1 | 50 | attr.id = 1 |
53 | ; attr.name = "particle" | 51 | attr.name = "particle" |
54 | 52 | ||
55 | ; ; Missing initialization fields default to zero. | 53 | ; Missing initialization fields default to zero. |
56 | ; vel = { -3 } | 54 | vel = vec { y = -3 } |
57 | ; } | 55 | } |