Add compiler tests for unions/matches

This commit is contained in:
Sasha Koshka 2024-03-06 15:06:21 -05:00
parent 9611e5ca72
commit 50e363b0da
5 changed files with 39 additions and 0 deletions

View File

@ -64,3 +64,20 @@ testUnit (test,
"", "well hello their\n",
0,
)}
func TestMatchExitCode (test *testing.T) {
testUnit (test,
"/test-data/data/matchexitcode", nil,
"", "",
7,
)}
func TestMatchPrint (test *testing.T) {
dependencies := []string {
compileDependency(test, "io"),
}
testUnit (test,
"/test-data/data/matchprint", dependencies,
"", "F64\n",
0,
)}

View File

@ -0,0 +1 @@
'839f0104-91f5-4db0-be52-6a17c571ebb1'

View File

@ -0,0 +1,9 @@
[main]: I32 'main' = {
x:F32 = 7.7
[matchToInt x]
}
U: (| I32 F32)
[matchToInt u:U]:I32 = match u in
| u:I32 u
| u:F32 [~I32 u]

View File

@ -0,0 +1,2 @@
'624d4557-5291-4ad7-9283-7c200b9c2942'
+ 'io'

View File

@ -0,0 +1,10 @@
[main]: I32 'main' = {
x:F64 = 7.7
[matchToInt x]
0
}
U: (| Int F64 UInt)
[matchToInt u:U] = match u in
| u:Int io::[println 'Int']
| u:F64 io::[println 'F64']