Skip to content

Commit 523f56e

Browse files
authored
test(c#): Add version runtime test (#814)
* Add csharp test Signed-off-by: James Sturtevant <[email protected]> * Fix the test Signed-off-by: James Sturtevant <[email protected]> --------- Signed-off-by: James Sturtevant <[email protected]>
1 parent 7c9c462 commit 523f56e

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

crates/csharp/README.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
// generate the c# and the component meta module
22

33
cargo run c-sharp --string-encoding utf8 --out-dir testing-csharp tests/codegen/floats.wit
4+
5+
// to run the runtime tests with Native AOT, you need some additional set up
6+
7+
// install emscripten
8+
curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip
9+
unzip main.zip
10+
cd .\emsdk-main\main\emsdk-main
11+
.\emsdk_env.ps1 activate 3.1.23 --permanant
12+
13+
// install wasi-sdk and set env
14+
curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz | tar xzvf -
15+
$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-20.0+m\"

tests/runtime/versions/wasm.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System.Diagnostics;
2+
using v1 = wit_foo.wit.imports.test.dep.v0_1_0.Test;
3+
using v2 = wit_foo.wit.imports.test.dep.v0_2_0.Test;
4+
5+
namespace wit_foo {
6+
7+
public class FooWorldImpl : IFooWorld
8+
{
9+
public static void TestImports()
10+
{
11+
Debug.Assert(v1.TestInterop.X() == 1.0f);
12+
Debug.Assert(v1.TestInterop.Y(1.0f) == 2.0f);
13+
14+
Debug.Assert(v2.TestInterop.X() == 2.0f);
15+
Debug.Assert(v2.TestInterop.Z(1.0f, 1.0f) == 4.0f);
16+
}
17+
}
18+
}
19+
20+
namespace wit_foo.wit.exports.test.dep.v0_1_0.Test {
21+
22+
23+
public class TestImpl : wit_foo.wit.exports.test.dep.v0_1_0.Test.ITest
24+
{
25+
public static float X() {
26+
return 1.0f;
27+
}
28+
29+
public static float Y(float a){
30+
return a + 1.0f;
31+
}
32+
}
33+
}
34+
35+
namespace wit_foo.wit.exports.test.dep.v0_2_0.Test {
36+
public class TestImpl : wit_foo.wit.exports.test.dep.v0_2_0.Test.ITest
37+
{
38+
public static float X() {
39+
return 2.0f;
40+
}
41+
42+
public static float Z(float a, float b){
43+
return a + b + 2.0f;
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)