Skip to content

Commit

Permalink
(#751) Tests: update test output, log all types in CodeGenArrayTests
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Dec 19, 2024
1 parent 3d48116 commit 429ea27
Show file tree
Hide file tree
Showing 38 changed files with 1,363 additions and 1,058 deletions.
8 changes: 3 additions & 5 deletions Cesium.CodeGen.Tests/CodeGenArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public class CodeGenArrayTests : CodeGenTestBase
private static Task DoTest([StringSyntax("cpp")] string source)
{
var assembly = GenerateAssembly(default, source);

var moduleType = assembly.Modules.Single().GetType("<Module>");
return VerifyMethods(moduleType);
return VerifyTypes(assembly);
}

[Fact]
Expand Down Expand Up @@ -245,8 +243,8 @@ int main() {
}
return 1;
}");
}");

[Fact]
public Task ConstExpressionSizeArrayTest() => DoTest(@"
int main() {
Expand Down
17 changes: 14 additions & 3 deletions Cesium.CodeGen.Tests/CodeGenTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Cesium.CodeGen.Contexts;
using Cesium.Core;
using Cesium.Parser;
using Cesium.Runtime;
using Cesium.TestFramework;
using JetBrains.Annotations;
using Mono.Cecil;
Expand Down Expand Up @@ -87,7 +88,7 @@ private static AssemblyContext CreateAssembly(
targetArchitectureSet,
ModuleKind.Console,
typeof(Math).Assembly.Location,
typeof(Runtime.RuntimeHelpers).Assembly.Location,
typeof(RuntimeHelpers).Assembly.Location,
allReferences,
@namespace,
globalTypeFqn,
Expand Down Expand Up @@ -212,8 +213,18 @@ private static void DumpTypes(IEnumerable<TypeDefinition> types, StringBuilder r
? initialValue.Length - 1
: initialValue.Length;
var value = Encoding.UTF8.GetString(initialValue, 0, length);
result.AppendLine(
$"{Indent(indent + 2)}Init with (UTF-8 x {initialValue.Length} bytes): \"{value}\"");
result.Append(
$"{Indent(indent + 2)}Init with (UTF-8 x {initialValue.Length} bytes): \"");
foreach (var c in value)
{
result.Append(c switch
{
_ when Char.IsControl(c) => $"\\{(int)c:X}",
_ => c
});
}

result.AppendLine("\"");
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
System.Int32* V_1
IL_0000: ldc.i4.s 40
IL_0002: conv.u
IL_0003: localloc
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.2
IL_0008: conv.i
IL_0009: ldc.i4 4
IL_000e: mul
IL_000f: add
IL_0010: stloc.1
IL_0011: ldc.i4.0
IL_0012: ret
Module: Primary
Type: <Module>
Methods:
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
System.Int32* V_1
IL_0000: ldc.i4.s 40
IL_0002: conv.u
IL_0003: localloc
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.2
IL_0008: conv.i
IL_0009: ldc.i4 4
IL_000e: mul
IL_000f: add
IL_0010: stloc.1
IL_0011: ldc.i4.0
IL_0012: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
System.Int32* V_1
IL_0000: ldc.i4.8
IL_0001: conv.u
IL_0002: localloc
IL_0004: stloc.0
IL_0005: ldsflda <ConstantPool>/<ConstantPoolItemType8> <ConstantPool>::ConstDataBuffer0
IL_000a: ldloc V_0
IL_000e: ldc.i4.8
IL_000f: conv.u
IL_0010: call System.Void Cesium.Runtime.RuntimeHelpers::InitializeCompound(System.Void*,System.Void*,System.UInt32)
IL_0015: ldloc.0
IL_0016: ldc.i4.4
IL_0017: ldc.i4.1
IL_0018: mul
IL_0019: add
IL_001a: stloc.1
IL_001b: ldloc.1
IL_001c: ldind.i4
IL_001d: ret
Module: Primary
Type: <Module>
Methods:
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
System.Int32* V_1
IL_0000: ldc.i4.8
IL_0001: conv.u
IL_0002: localloc
IL_0004: stloc.0
IL_0005: ldsflda <ConstantPool>/<ConstantPoolItemType8> <ConstantPool>::ConstDataBuffer0
IL_000a: ldloc V_0
IL_000e: ldc.i4.8
IL_000f: conv.u
IL_0010: call System.Void Cesium.Runtime.RuntimeHelpers::InitializeCompound(System.Void*,System.Void*,System.UInt32)
IL_0015: ldloc.0
IL_0016: ldc.i4.4
IL_0017: ldc.i4.1
IL_0018: mul
IL_0019: add
IL_001a: stloc.1
IL_001b: ldloc.1
IL_001c: ldind.i4
IL_001d: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret

Type: <ConstantPool>
Nested types:
Type: <ConstantPool>/<ConstantPoolItemType8>
Pack: 1
Size: 8
Fields:
<ConstantPool>/<ConstantPoolItemType8> <ConstantPool>::ConstDataBuffer0
Init with (UTF-8 x 8 bytes): "\0\0\0\0\0\0\0"
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
IL_0000: ldc.i4.s 40
IL_0002: conv.u
IL_0003: localloc
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.1
IL_0008: conv.i
IL_0009: ldc.i4 4
IL_000e: mul
IL_000f: add
IL_0010: ldc.i4.2
IL_0011: stind.i4
IL_0012: ldloc.0
IL_0013: ldc.i4.1
IL_0014: conv.i
IL_0015: ldc.i4 4
IL_001a: mul
IL_001b: add
IL_001c: ldind.i4
IL_001d: ret
Module: Primary
Type: <Module>
Methods:
System.Int32 <Module>::main()
Locals:
System.Int32* V_0
IL_0000: ldc.i4.s 40
IL_0002: conv.u
IL_0003: localloc
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldc.i4.1
IL_0008: conv.i
IL_0009: ldc.i4 4
IL_000e: mul
IL_000f: add
IL_0010: ldc.i4.2
IL_0011: stind.i4
IL_0012: ldloc.0
IL_0013: ldc.i4.1
IL_0014: conv.i
IL_0015: ldc.i4 4
IL_001a: mul
IL_001b: add
IL_001c: ldind.i4
IL_001d: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
System.Int32 <Module>::main()
Locals:
System.Byte* V_0
IL_0000: ldc.i4.1
IL_0001: conv.u
IL_0002: localloc
IL_0004: stloc.0
IL_0005: ldsflda <ConstantPool>/<ConstantPoolItemType1> <ConstantPool>::ConstDataBuffer0
IL_000a: ldloc V_0
IL_000e: ldc.i4.1
IL_000f: conv.u
IL_0010: call System.Void Cesium.Runtime.RuntimeHelpers::InitializeCompound(System.Void*,System.Void*,System.UInt32)
IL_0015: ldloc.0
IL_0016: ldc.i4.0
IL_0017: conv.i
IL_0018: ldc.i4 1
IL_001d: mul
IL_001e: add
IL_001f: ldind.i1
IL_0020: ldc.i4.s 68
IL_0022: conv.u1
IL_0023: ceq
IL_0025: ldc.i4.0
IL_0026: ceq
IL_0028: brfalse IL_002f
IL_002d: ldc.i4.0
IL_002e: ret
IL_002f: nop
IL_0030: ldc.i4.1
IL_0031: ret
Module: Primary
Type: <Module>
Methods:
System.Int32 <Module>::main()
Locals:
System.Byte* V_0
IL_0000: ldc.i4.1
IL_0001: conv.u
IL_0002: localloc
IL_0004: stloc.0
IL_0005: ldsflda <ConstantPool>/<ConstantPoolItemType1> <ConstantPool>::ConstDataBuffer0
IL_000a: ldloc V_0
IL_000e: ldc.i4.1
IL_000f: conv.u
IL_0010: call System.Void Cesium.Runtime.RuntimeHelpers::InitializeCompound(System.Void*,System.Void*,System.UInt32)
IL_0015: ldloc.0
IL_0016: ldc.i4.0
IL_0017: conv.i
IL_0018: ldc.i4 1
IL_001d: mul
IL_001e: add
IL_001f: ldind.i1
IL_0020: ldc.i4.s 68
IL_0022: conv.u1
IL_0023: ceq
IL_0025: ldc.i4.0
IL_0026: ceq
IL_0028: brfalse IL_002f
IL_002d: ldc.i4.0
IL_002e: ret
IL_002f: nop
IL_0030: ldc.i4.1
IL_0031: ret

System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret
System.Int32 <Module>::<SyntheticEntrypoint>()
Locals:
System.Int32 V_0
IL_0000: call System.Int32 <Module>::main()
IL_0005: stloc.s V_0
IL_0007: ldloc.s V_0
IL_0009: call System.Void Cesium.Runtime.RuntimeHelpers::Exit(System.Int32)
IL_000e: ldloc.s V_0
IL_0010: ret

Type: <ConstantPool>
Nested types:
Type: <ConstantPool>/<ConstantPoolItemType1>
Pack: 1
Size: 1
Fields:
<ConstantPool>/<ConstantPoolItemType1> <ConstantPool>::ConstDataBuffer0
Init with (UTF-8 x 1 bytes): "A"
Loading

0 comments on commit 429ea27

Please sign in to comment.