* Add a wasmtime-specific `wasmtime_wat2wasm` C API This commit implements a wasmtime-specific C API for converting the text format to the binary format. An upstream spec issue exists for adding this to the C API, but in the meantime we can experiment with our own version of this API and use it in the C# extension, for example! Closes #1000 * Reorder arguments * Use wasm_byte_vec_t for input `*.wat` * Mark wat input as const * Return an error message and use `fixed` * Actually include the error message * Use `fixed` in `Module.cs` as well
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace Wasmtime.Tests
|
|
{
|
|
public class TableExportsFixture : ModuleFixture
|
|
{
|
|
protected override string ModuleFileName => "TableExports.wat";
|
|
}
|
|
|
|
public class TableExportsTests : IClassFixture<TableExportsFixture>
|
|
{
|
|
public TableExportsTests(TableExportsFixture fixture)
|
|
{
|
|
Fixture = fixture;
|
|
}
|
|
|
|
private TableExportsFixture Fixture { get; set; }
|
|
|
|
[Theory]
|
|
[MemberData(nameof(GetTableExports))]
|
|
public void ItHasTheExpectedTableExports(string exportName, ValueKind expectedKind, uint expectedMinimum, uint expectedMaximum)
|
|
{
|
|
var export = Fixture.Module.Exports.Tables.Where(f => f.Name == exportName).FirstOrDefault();
|
|
export.Should().NotBeNull();
|
|
export.Kind.Should().Be(expectedKind);
|
|
export.Minimum.Should().Be(expectedMinimum);
|
|
export.Maximum.Should().Be(expectedMaximum);
|
|
}
|
|
|
|
[Fact]
|
|
public void ItHasTheExpectedNumberOfExportedTables()
|
|
{
|
|
GetTableExports().Count().Should().Be(Fixture.Module.Exports.Tables.Count);
|
|
}
|
|
|
|
public static IEnumerable<object[]> GetTableExports()
|
|
{
|
|
yield return new object[] {
|
|
"table1",
|
|
ValueKind.FuncRef,
|
|
1,
|
|
10
|
|
};
|
|
|
|
yield return new object[] {
|
|
"table2",
|
|
ValueKind.AnyRef,
|
|
10,
|
|
uint.MaxValue
|
|
};
|
|
|
|
yield return new object[] {
|
|
"table3",
|
|
ValueKind.FuncRef,
|
|
100,
|
|
1000
|
|
};
|
|
}
|
|
}
|
|
}
|