Add compiler tests for unions/matches
This commit is contained in:
parent
9611e5ca72
commit
50e363b0da
@ -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,
|
||||
)}
|
||||
|
1
compiler/test-data/data/matchexitcode/fspl.mod
Normal file
1
compiler/test-data/data/matchexitcode/fspl.mod
Normal file
@ -0,0 +1 @@
|
||||
'839f0104-91f5-4db0-be52-6a17c571ebb1'
|
9
compiler/test-data/data/matchexitcode/main.fspl
Normal file
9
compiler/test-data/data/matchexitcode/main.fspl
Normal 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]
|
2
compiler/test-data/data/matchprint/fspl.mod
Normal file
2
compiler/test-data/data/matchprint/fspl.mod
Normal file
@ -0,0 +1,2 @@
|
||||
'624d4557-5291-4ad7-9283-7c200b9c2942'
|
||||
+ 'io'
|
10
compiler/test-data/data/matchprint/main.fspl
Normal file
10
compiler/test-data/data/matchprint/main.fspl
Normal 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']
|
Loading…
Reference in New Issue
Block a user