Skip to content

Commit

Permalink
Enable runtime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yowl committed Jan 19, 2024
1 parent a11e714 commit 511b6bd
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 57 deletions.
10 changes: 5 additions & 5 deletions crates/csharp/src/csproj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl CSProjectLLVMBuilder {
pub fn generate(&self) -> Result<()> {
let name = &self.name;
let world = &self.world_name.replace("-", "_");
let snake_world = world.to_upper_camel_case();
// TODO remove snake_world?
let snake_world = format!("{}World", world.to_upper_camel_case());
let camel = snake_world.to_upper_camel_case();

fs::write(
Expand Down Expand Up @@ -79,7 +80,7 @@ impl CSProjectLLVMBuilder {
<AssemblyName>{name}</AssemblyName>
</PropertyGroup>
<ItemGroup>
<NativeLibrary Include=\"{world}_component_type.o\" />
<NativeLibrary Include=\"{camel}_component_type.o\" />
<NativeLibrary Include=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\" />
</ItemGroup>
Expand Down Expand Up @@ -182,7 +183,7 @@ impl CSProjectMonoBuilder {
pub fn generate(&self) -> Result<()> {
let name = &self.name;
let world = &self.world_name.replace("-", "_");
let snake_world = world.to_upper_camel_case();
let camel = format!("{}World", world.to_upper_camel_case());

let aot = self.aot;

Expand Down Expand Up @@ -228,7 +229,7 @@ impl CSProjectMonoBuilder {
</PropertyGroup>
<ItemGroup>
<NativeLibrary Include=\"{world}_component_type.o\" />
<NativeLibrary Include=\"{camel}_component_type.o\" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -277,7 +278,6 @@ impl CSProjectMonoBuilder {
"#,
);

let camel = snake_world.to_upper_camel_case();
fs::write(self.dir.join(format!("{camel}.csproj")), csproj)?;

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions crates/csharp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl WorldGenerator for CSharp {
"#,
);
files.push(
&format!("{name}_cabi_realloc.c"),
&format!("{name}World_cabi_realloc.c"),
indent(&cabi_relloc_src).as_bytes(),
);

Expand Down Expand Up @@ -984,7 +984,7 @@ impl InterfaceGenerator<'_> {
let types = func
.results
.iter_types()
.map(|ty| self.type_name(ty))
.map(|ty| self.type_name_with_qualifier(ty, true))
.collect::<Vec<_>>()
.join(", ");
format!("({})", types)
Expand Down
1 change: 0 additions & 1 deletion crates/csharp/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ macro_rules! codegen_test {
"keywords",
"lift-lower-foreign",
"lists",
"many-arguments",
"option-result",
"rename-interface",
"resource-alias",
Expand Down
56 changes: 23 additions & 33 deletions tests/codegen/many-arguments.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
package many:arguments;
package test:many-arguments;

interface manyarg {
many-args: func(
world many-arguments {
import imports: interface {
many-arguments: func(
a1: u64,
a2: u64,
a3: u64,
a4: u64,
a5: u64,
a6: u64,
a7: u64,
a8: u64,
a9: u64,
a10: u64,
a11: u64,
a12: u64,
a13: u64,
a14: u64,
a15: u64,
a16: u64,
);
}
export many-arguments: func(
a1: u64,
a2: u64,
a3: u64,
Expand All @@ -19,34 +39,4 @@ interface manyarg {
a15: u64,
a16: u64,
);

record big-struct {
a1: string,
a2: string,
a3: string,
a4: string,
a5: string,
a6: string,
a7: string,
a8: string,
a9: string,
a10: string,
a11: string,
a12: string,
a13: string,
a14: string,
a15: string,
a16: string,
a17: string,
a18: string,
a19: string,
a20: string,
}

big-argument: func(x: big-struct);
}

world the-world {
import manyarg;
export manyarg;
}
4 changes: 2 additions & 2 deletions tests/runtime/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> {
}

let snake = world_name.replace("-", "_");
let camel = snake.to_upper_camel_case();
let camel = format!("{}World", snake.to_upper_camel_case());

let assembly_name = format!(
"csharp-{}",
Expand Down Expand Up @@ -661,7 +661,7 @@ fn tests(name: &str, dir_name: &str) -> Result<Vec<PathBuf>> {
}

let snake = world_name.replace("-", "_");
let camel = snake.to_upper_camel_case();
let camel = format!("{}World", snake.to_upper_camel_case());

let assembly_name = format!(
"csharp-{}",
Expand Down
5 changes: 3 additions & 2 deletions tests/runtime/many_arguments/wasm.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Diagnostics;
using wit_many_arguments.wit.imports.Imports;
using ManyArgumentsWorld;
using ManyArgumentsWorld.wit.imports;

namespace wit_many_arguments;
namespace ManyArgumentsWorld;

public class ManyArgumentsWorldImpl : IManyArgumentsWorld
{
Expand Down
9 changes: 4 additions & 5 deletions tests/runtime/numbers/wasm.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using wit_numbers.wit.imports.test.numbers.Test;
using NumbersWorld.wit.imports.test.numbers;

namespace wit_numbers
namespace NumbersWorld
{

public class NumbersWorldImpl : INumbersWorld
Expand Down Expand Up @@ -65,9 +65,9 @@ public static void TestImports()
}
}

namespace wit_numbers.wit.exports.test.numbers.Test
namespace NumbersWorld.wit.exports.test.numbers
{
public class TestImpl : wit_numbers.wit.exports.test.numbers.Test.ITest
public class TestImpl : ITest
{
static uint SCALAR = 0;

Expand Down Expand Up @@ -137,4 +137,3 @@ public static uint GetScalar()
}
}
}

6 changes: 3 additions & 3 deletions tests/runtime/records/wasm.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;
using wit_records.wit.imports.test.records.Test;
using RecordsWorld.wit.imports.test.records;

namespace wit_records.exports
namespace RecordsWorld
{
public class RecordsWorldImpl : IRecordsWorld
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public static void TestImports()

}

namespace wit_records.wit.exports.test.records.Test
namespace RecordsWorld.wit.exports.test.records
{
public class TestImpl : ITest
{
Expand Down
5 changes: 3 additions & 2 deletions tests/runtime/smoke/wasm.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Diagnostics;
using wit_smoke.wit.imports.test.smoke.Imports;
using SmokeWorld;
using SmokeWorld.wit.imports.test.smoke;

namespace wit_smoke;
namespace SmokeWorld;

public class SmokeWorldImpl : ISmokeWorld
{
Expand Down
4 changes: 2 additions & 2 deletions tests/runtime/strings/wasm.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Diagnostics;
using wit_strings.wit.imports.test.strings.Imports;
using StringsWorld.wit.imports.test.strings;

namespace wit_strings;
namespace StringsWorld;

public class StringsWorldImpl : IStringsWorld
{
Expand Down

0 comments on commit 511b6bd

Please sign in to comment.