Add some tests for the union type

This commit is contained in:
Sasha Koshka 2024-03-02 12:26:16 -05:00
parent e38ba2f4e2
commit aacf1be026

View File

@ -148,6 +148,29 @@ Bird: (.
`)
}
func TestTypeUnion (test *testing.T) {
testString (test,
`
U: (| I8 I16 I32 I64 Int)
Point: (. x:Int y:Int)
Error: (~ [error]:String)
PointOrError: (| Point Error)
`)
}
func TestTypeUnionAllowedUniqueErr (test *testing.T) {
testStringErr (test,
"(. x:Int) already listed in union at stream0.fspl:5:3", 7, 3,
`
U: (|
U8
U16
(. x:Int)
Int
(. x:Int))
`)
}
func TestTypeInterfaceBehaviorUniqueErr (test *testing.T) {
testStringErr (test,
"fly already listed in interface at stream0.fspl:2:10", 2, 16,