Skip to content

Commit 4aaf2f6

Browse files
authored
feat: add more invalid tests (#1699)
This adds several additional invalid tests which span the boundaries between linking / typing / cfg / cycle detection. Specifically, where errors arise across two of these areas.
1 parent ef70238 commit 4aaf2f6

5 files changed

Lines changed: 51 additions & 0 deletions

File tree

pkg/test/zkc_invalid_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ func Test_ZkcInvalid_Basic_27(t *testing.T) {
125125
checkZkcInvalid(t, "zkc/invalid/basic_27")
126126
}
127127

128+
func Test_ZkcInvalid_Basic_28(t *testing.T) {
129+
checkZkcInvalid(t, "zkc/invalid/basic_28")
130+
}
131+
func Test_ZkcInvalid_Basic_29(t *testing.T) {
132+
checkZkcInvalid(t, "zkc/invalid/basic_29")
133+
}
134+
func Test_ZkcInvalid_Basic_30(t *testing.T) {
135+
checkZkcInvalid(t, "zkc/invalid/basic_30")
136+
}
137+
func Test_ZkcInvalid_Basic_31(t *testing.T) {
138+
checkZkcInvalid(t, "zkc/invalid/basic_31")
139+
}
140+
128141
// ===================================================================
129142
// If Tests
130143
// ===================================================================

testdata/zkc/invalid/basic_28.zkc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//error:11:7-11:too many arguments (expected 0)
2+
//error:7:11-12:expected type u16
3+
const X:u32 = 123
4+
5+
fn f(y:u16) -> (r:u32) {
6+
//
7+
if y != X {
8+
fail
9+
}
10+
//
11+
r = X(0)
12+
}

testdata/zkc/invalid/basic_29.zkc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//error:7:7-11:too many arguments (expected 0)
2+
//error:4:1-21:cyclic definition for cyclic
3+
const X:u32 = 123
4+
type cyclic = cyclic
5+
6+
fn f(y:u16) -> (r:u32) {
7+
r = X(0)
8+
}

testdata/zkc/invalid/basic_30.zkc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//error:7:10-14:too many arguments (expected 0)
2+
//error:9:1-2:return r possibly undefined
3+
const X:u32 = 123
4+
5+
fn f(y:u16) -> (r:u32) {
6+
if y != 0 {
7+
r = X(0)
8+
}
9+
}

testdata/zkc/invalid/basic_31.zkc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//error:7:10-11:expected type u32
2+
//error:9:1-2:return r possibly undefined
3+
const X:u16 = 123
4+
5+
fn f(y:u16) -> (r:u32) {
6+
if y != 0 {
7+
r = X
8+
}
9+
}

0 commit comments

Comments
 (0)