Skip to content

Commit

Permalink
Adding Transpiled test for tailcall
Browse files Browse the repository at this point in the history
  • Loading branch information
kelnishi committed Dec 4, 2024
1 parent fb4f9cf commit ab58880
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Spec.Test/ExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ public class ExtensionTests
public void TailCallFactorial()
{
var runtime = new WasmRuntime();
runtime.TranspileModules = false;

using var fileStream = new FileStream("../../../engine/tailcalls.wasm", FileMode.Open);
var module = BinaryModuleParser.ParseWasm(fileStream);
var moduleInst = runtime.InstantiateModule(module);
runtime.RegisterModule("tailcalls", moduleInst);

var fa = runtime.GetExportedFunction(("tailcalls", "factorial"));
var invoker = runtime.CreateInvoker<Func<long, long>>(fa);

Assert.Equal(479_001_600, invoker(12));
Assert.Equal(2_432_902_008_176_640_000 , invoker(20));
}

[Fact]
public void TailCallFactorialTranspiled()
{
var runtime = new WasmRuntime();
runtime.TranspileModules = true;

using var fileStream = new FileStream("../../../engine/tailcalls.wasm", FileMode.Open);
var module = BinaryModuleParser.ParseWasm(fileStream);
Expand Down

0 comments on commit ab58880

Please sign in to comment.