Skip to content

Commit

Permalink
(#354) Fix compilation, deduplicate some redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Oct 30, 2023
1 parent a653fb7 commit 3f530d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
19 changes: 16 additions & 3 deletions Cesium.CodeGen.Tests/ArchitectureDependentCodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations;

namespace Cesium.CodeGen.Tests;

public class ArchitectureDependentCodeTests : CodeGenTestBase
{
[MustUseReturnValue]
private static Task DoTest(TargetArchitectureSet arch, string source)
private static Task DoTest(TargetArchitectureSet arch, [StringSyntax("cpp")] string source)
{
var assembly = GenerateAssembly(runtime: default, arch: arch, sources: source);
return VerifyTypes(assembly, arch);
Expand Down Expand Up @@ -93,8 +94,6 @@ public Task FunctionPointerParameter(TargetArchitectureSet arch) => DoTest(arch,
int foo(func x) { return 0; }
int v_foo(v_func x) { return 0; }
""");
// TODO: empty-paren-func ptr
// TODO: vararg-func ptr

[Theory]
[InlineData(TargetArchitectureSet.Dynamic)]
Expand All @@ -107,5 +106,19 @@ struct Foo
{
func x;
};
""");
// TODO: empty-paren-func ptr
// TODO: vararg-func ptr

[Theory]
[InlineData(TargetArchitectureSet.Dynamic)]
[InlineData(TargetArchitectureSet.Bit64)]
[InlineData(TargetArchitectureSet.Bit32)]
[InlineData(TargetArchitectureSet.Wide)]
public Task StructWithNestedFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """
typedef struct
{
int (*func)(int(*)(void));
} foo;
""");
}
20 changes: 0 additions & 20 deletions Cesium.CodeGen.Tests/ArchitectureDependentTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,4 @@ typedef struct
""",
"Cannot statically determine a size of type",
arch: TargetArchitectureSet.Dynamic);

[Theory]
[InlineData(TargetArchitectureSet.Dynamic)]
[InlineData(TargetArchitectureSet.Wide)]
public Task StructWithFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """
typedef struct
{
int (*func)(int);
} foo;
""");

[Theory]
[InlineData(TargetArchitectureSet.Dynamic)]
[InlineData(TargetArchitectureSet.Wide)]
public Task StructWithNestedFuncPtr(TargetArchitectureSet arch) => DoTest(arch, """
typedef struct
{
int (*func)(int(*)(void));
} foo;
""");
}
2 changes: 2 additions & 0 deletions Cesium.Runtime/StdIoFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#if NETSTANDARD
using System.Text;
#else
using System.Runtime.InteropServices;
#endif

namespace Cesium.Runtime;
Expand Down

0 comments on commit 3f530d6

Please sign in to comment.