Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions examples/addition.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module Test

let main () =
let first = 23
let second = 89
first + second
9 + 11
6 changes: 6 additions & 0 deletions examples/additionVars.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Test

let main () =
let first = 23
let second = 89
first + second
4 changes: 4 additions & 0 deletions examples/multipleAdditions.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Test

let main () =
9 + 11 + 4 + 6
4 changes: 4 additions & 0 deletions examples/subtraction.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Test

let main () =
10 - 5
36 changes: 36 additions & 0 deletions test/AstToWasmTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,42 @@ let getModuleSymbols (moduleSymbols: ModuleSymbolList) =



[<Fact>]
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)

[<Fact>]
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)

[<Theory>]
[<InlineData("1", 1)>]
[<InlineData("1 + 3", 4)>]
Expand Down