Skip to content

Commit

Permalink
Add nested class constructors test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Washi1337 committed Mar 22, 2024
1 parent 8cb57ac commit 4ff94aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,23 @@ public void CallAndThrowUnhandledException(string methodName, object parameter)
Assert.Equal(expectedException.GetType().FullName, result.ExceptionObject.GetObjectType().FullName);
}

[Fact]
public void SteppingWithNestedInitializers()
{
// Look up metadata.
var method = _fixture
.MockModule.LookupMember<TypeDefinition>(typeof(ClassWithNestedInitializer.Class1).MetadataToken)
.Methods.First(m => m.Name == nameof(ClassWithNestedInitializer.Class1.Method));

// CAll method.
_vm.Invoker = DefaultInvokers.StepIn;
var result = _mainThread.Call(method, Array.Empty<BitVector>());

// Verify.
Assert.NotNull(result);
Assert.Equal(1337, result.AsSpan().I32);

Check warning on line 605 in test/Platforms/Echo.Platforms.AsmResolver.Tests/Emulation/CilVirtualMachineTest.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 605 in test/Platforms/Echo.Platforms.AsmResolver.Tests/Emulation/CilVirtualMachineTest.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 605 in test/Platforms/Echo.Platforms.AsmResolver.Tests/Emulation/CilVirtualMachineTest.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

[Fact]
public void StaticFieldWithInitialValueUpdate()
{
Expand Down
16 changes: 16 additions & 0 deletions test/Platforms/Mocks/ClassWithNestedInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Mocks;

public class ClassWithNestedInitializer
{
public class Class1
{
public static int Field = Class2.Field;

public static int Method() => Field;
}

public class Class2
{
public static int Field = 1337;
}
}

0 comments on commit 4ff94aa

Please sign in to comment.