-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* - Added methods to fetch all exports from an instance - Removed `wasmtime_instancetype_delete` (doesn't appear to be part of the c-api any more) * Added another import with no module name * Update tests/InstanceTests.cs Co-authored-by: Konstantin Preißer <[email protected]> * Apply suggestions from code review Co-authored-by: Peter Huene <[email protected]> * Removed unnecessary doc comment on private method --------- Co-authored-by: Konstantin Preißer <[email protected]> Co-authored-by: Peter Huene <[email protected]>
- Loading branch information
1 parent
bd71441
commit c976fb2
Showing
2 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Wasmtime.Tests | ||
{ | ||
public class InstanceFixture | ||
: ModuleFixture | ||
{ | ||
protected override string ModuleFileName => "hello.wat"; | ||
} | ||
|
||
public class InstanceTests | ||
: IClassFixture<InstanceFixture>, IDisposable | ||
{ | ||
private Store Store { get; set; } | ||
|
||
private Linker Linker { get; set; } | ||
|
||
public InstanceTests(InstanceFixture fixture) | ||
{ | ||
Fixture = fixture; | ||
Linker = new Linker(Fixture.Engine); | ||
Store = new Store(Fixture.Engine); | ||
|
||
Linker.DefineFunction("env", "add", (int x, int y) => x + y); | ||
Linker.DefineFunction("env", "swap", (int x, int y) => (y, x)); | ||
Linker.DefineFunction("", "hi", (int x, int y) => (y, x)); | ||
|
||
Linker.DefineFunction("", "hello", () => { }); | ||
} | ||
|
||
private InstanceFixture Fixture { get; } | ||
|
||
[Fact] | ||
public void ItGetsExportedFunctions() | ||
{ | ||
var instance = Linker.Instantiate(Store, Fixture.Module); | ||
|
||
var results = instance.GetFunctions(); | ||
|
||
results.Single().Name.Should().Be("run"); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Store.Dispose(); | ||
Linker.Dispose(); | ||
} | ||
} | ||
} |