aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2024-06-24 17:28:46 +0200
committerBad Diode <bd@badd10de.dev>2024-06-24 17:28:46 +0200
commit2560da172f15982da7464a6534702c08f9b7575d (patch)
tree29dd60aeb65e40c17e52b5bad677502dbb18e163 /tests
parent6d8b7b0bf66d22d6de13474b18617204adfe32e9 (diff)
downloadbdl-2560da172f15982da7464a6534702c08f9b7575d.tar.gz
bdl-2560da172f15982da7464a6534702c08f9b7575d.zip
Add typechecking for enum fields
Diffstat (limited to 'tests')
-rw-r--r--tests/comparisons.bad4
-rw-r--r--tests/conditionals.bad8
-rw-r--r--tests/semantics.bad43
3 files changed, 30 insertions, 25 deletions
diff --git a/tests/comparisons.bad b/tests/comparisons.bad
index 7bc5d33..512feac 100644
--- a/tests/comparisons.bad
+++ b/tests/comparisons.bad
@@ -7,7 +7,3 @@ true != false
72 >= 1 && 2 > 1 72 >= 1 && 2 > 1
83 >= 3 || 4 <= 5 83 >= 3 || 4 <= 5
94 < (5 + 6) == true 94 < (5 + 6) == true
10
11nil != false
12nil != true
13nil != 1
diff --git a/tests/conditionals.bad b/tests/conditionals.bad
index b5ef61f..50d0cfc 100644
--- a/tests/conditionals.bad
+++ b/tests/conditionals.bad
@@ -5,7 +5,7 @@ if (true) "hello"
5let a = if (2 + 2 >= 4) 42 5let a = if (2 + 2 >= 4) 42
6 6
7; We support a single if expression. 7; We support a single if expression.
8let b = if (0xff == 255) "hello" else "world" 8let b = if (0xff == 0x32) "hello" else "world"
9 9
10; ... but these can compound on each other 10; ... but these can compound on each other
11if (1 < 2) 6 11if (1 < 2) 6
@@ -51,7 +51,7 @@ match (a) {
51; Conditional `cond` statements are syntactic sugar for a chain of if-else 51; Conditional `cond` statements are syntactic sugar for a chain of if-else
52; statements. 52; statements.
53let msg:str = cond { 53let msg:str = cond {
54 case a == b = "hello" 54 a == 1 = "hello"
55 case a != f = "world" 55 a != 2 = "world"
56 else = "what" 56 else = "what"
57} 57}
diff --git a/tests/semantics.bad b/tests/semantics.bad
index 3479915..ee56c14 100644
--- a/tests/semantics.bad
+++ b/tests/semantics.bad
@@ -1,10 +1,19 @@
1fun add10(a: int, b: str): int { 1enum weekdays {
2 a + 10 2 mon = 1
3 tue
4 wed
5 thu
6 fri
7 sat
8 sun
3} 9}
10; fun add10(a: int, b: str): int {
11; a + 10
12; }
4 13
5fun foo(): int { 14; fun foo(): int {
6 add10(1, "hello") 15; add10(1, "hello")
7} 16; }
8 17
9; let a:f32 = (1.0 + 2.0 * 2.0) / 2.0 18; let a:f32 = (1.0 + 2.0 * 2.0) / 2.0
10 19
@@ -54,18 +63,18 @@ fun foo(): int {
54; let a:my_struct 63; let a:my_struct
55; set a.field_a = 1 64; set a.field_a = 1
56 65
57fun nested(): int { 66; fun nested(): int {
58 fun adder(a: u32, b: u32): u32 { 67; fun adder(a: u32, b: u32): u32 {
59 a + b 68; a + b
60 } 69; }
61 if (1 + 1 == 2) { 70; if (1 + 1 == 2) {
62 let b = 15 71; let b = 15
63 5 + b 72; {
64 ; { 73; let c = 32
65 ; let b = 32 74; 5 + c
66 ; } 75; }
67 } 76; }
68} 77; }
69 78
70; enum field { 79; enum field {
71; a 80; a