diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 783b26b..47bb314 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -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, +)} diff --git a/compiler/test-data/data/matchexitcode/fspl.mod b/compiler/test-data/data/matchexitcode/fspl.mod new file mode 100644 index 0000000..40c2703 --- /dev/null +++ b/compiler/test-data/data/matchexitcode/fspl.mod @@ -0,0 +1 @@ +'839f0104-91f5-4db0-be52-6a17c571ebb1' diff --git a/compiler/test-data/data/matchexitcode/main.fspl b/compiler/test-data/data/matchexitcode/main.fspl new file mode 100644 index 0000000..118990c --- /dev/null +++ b/compiler/test-data/data/matchexitcode/main.fspl @@ -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] diff --git a/compiler/test-data/data/matchprint/fspl.mod b/compiler/test-data/data/matchprint/fspl.mod new file mode 100644 index 0000000..bd8d3c7 --- /dev/null +++ b/compiler/test-data/data/matchprint/fspl.mod @@ -0,0 +1,2 @@ +'624d4557-5291-4ad7-9283-7c200b9c2942' ++ 'io' diff --git a/compiler/test-data/data/matchprint/main.fspl b/compiler/test-data/data/matchprint/main.fspl new file mode 100644 index 0000000..0910bf0 --- /dev/null +++ b/compiler/test-data/data/matchprint/main.fspl @@ -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']