Add union assignment tests to analyzer

This commit is contained in:
Sasha Koshka 2024-03-06 13:50:55 -05:00
parent 98d8edc319
commit 41116e0b13
1 changed files with 34 additions and 0 deletions

View File

@ -249,6 +249,40 @@ BlueJay.[land] = { }
`)
}
func TestAssignmentUnion (test *testing.T) {
testString (test,
`
U: (| Int F64)
[main] = {
x:F64 = 7.7
y:U = x
}
`)
}
func TestAssignmentUnionToUnion (test *testing.T) {
testString (test,
`
U: (| Int F64)
[main] = {
x:U y:U
x = y
}
`)
}
func TestAssignmentUnionErrNotListed (test *testing.T) {
testStringErr (test,
"I64 is not included within union (| Int F64)", 5, 8,
`
U: (| Int F64)
[main] = {
x:I64 = 7
y:U = x
}
`)
}
func TestAssignmentErrByteSliceString (test *testing.T) {
testStringErr (test,
"expected *:Byte", 4, 13,