Favor using non-braced using statement.
This commit is contained in:
@@ -36,36 +36,34 @@ namespace Wasmtime.Tests
|
||||
public void ItBindsImportMethodsAndCallsThemCorrectly()
|
||||
{
|
||||
var host = new MyHost();
|
||||
using (var instance = Fixture.Module.Instantiate(host))
|
||||
{
|
||||
var add_func = instance.Externs.Functions.Where(f => f.Name == "add_wrapper").Single();
|
||||
int invoke_add(int x, int y) => (int)add_func.Invoke(new object[] { x, y });
|
||||
using var instance = Fixture.Module.Instantiate(host);
|
||||
|
||||
invoke_add(40, 2).Should().Be(42);
|
||||
invoke_add(22, 5).Should().Be(27);
|
||||
var add_func = instance.Externs.Functions.Where(f => f.Name == "add_wrapper").Single();
|
||||
int invoke_add(int x, int y) => (int)add_func.Invoke(new object[] { x, y });
|
||||
|
||||
//Collect garbage to make sure delegate function pointers pasted to wasmtime are rooted.
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
invoke_add(40, 2).Should().Be(42);
|
||||
invoke_add(22, 5).Should().Be(27);
|
||||
|
||||
invoke_add(1970, 50).Should().Be(2020);
|
||||
}
|
||||
//Collect garbage to make sure delegate function pointers pasted to wasmtime are rooted.
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
invoke_add(1970, 50).Should().Be(2020);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPropagatesExceptionsToCallersViaTraps()
|
||||
{
|
||||
var host = new MyHost();
|
||||
using (var instance = Fixture.Module.Instantiate(host))
|
||||
{
|
||||
var throw_func = instance.Externs.Functions.Where(f => f.Name == "do_throw_wrapper").Single();
|
||||
Action action = () => throw_func.Invoke();
|
||||
using var instance = Fixture.Module.Instantiate(host);
|
||||
|
||||
action
|
||||
.Should()
|
||||
.Throw<TrapException>()
|
||||
.WithMessage(THROW_MESSAGE);
|
||||
}
|
||||
var throw_func = instance.Externs.Functions.Where(f => f.Name == "do_throw_wrapper").Single();
|
||||
Action action = () => throw_func.Invoke();
|
||||
|
||||
action
|
||||
.Should()
|
||||
.Throw<TrapException>()
|
||||
.WithMessage(THROW_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user