diff --git a/examples/addition.fs b/examples/addition.fs index b3fbd99..8f31b4d 100644 --- a/examples/addition.fs +++ b/examples/addition.fs @@ -1,6 +1,4 @@ module Test let main () = - let first = 23 - let second = 89 - first + second + 9 + 11 diff --git a/examples/additionVars.fs b/examples/additionVars.fs new file mode 100644 index 0000000..b3fbd99 --- /dev/null +++ b/examples/additionVars.fs @@ -0,0 +1,6 @@ +module Test + +let main () = + let first = 23 + let second = 89 + first + second diff --git a/examples/multipleAdditions.fs b/examples/multipleAdditions.fs new file mode 100644 index 0000000..d2a1875 --- /dev/null +++ b/examples/multipleAdditions.fs @@ -0,0 +1,4 @@ +module Test + +let main () = + 9 + 11 + 4 + 6 diff --git a/examples/subtraction.fs b/examples/subtraction.fs new file mode 100644 index 0000000..4b83c05 --- /dev/null +++ b/examples/subtraction.fs @@ -0,0 +1,4 @@ +module Test + +let main () = + 10 - 5 diff --git a/test/AstToWasmTests.fs b/test/AstToWasmTests.fs index 4eb47be..3ab8115 100644 --- a/test/AstToWasmTests.fs +++ b/test/AstToWasmTests.fs @@ -18,6 +18,42 @@ let getModuleSymbols (moduleSymbols: ModuleSymbolList) = +[] +let ``Can run simple main function`` () = + let input = + $""" +module Test + +let main () = 23 +""" + + let declarations = getDeclarations checker input + let wasmBytes = astToWasm declarations + + //printWasm wasmBytes + + let response = wasmBytes |> runFuncInt32Return "main" + response.Should().Be(23) + +[] +let ``Can compile multiple functions`` () = + let input = + $""" +module Test + +let second () = 24 +let third () = 24 +let main () = 23 +""" + + let declarations = getDeclarations checker input + let wasmBytes = astToWasm declarations + + //printWasm wasmBytes + + let response = wasmBytes |> runFuncInt32Return "main" + response.Should().Be(23) + [] [] []