Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdageek committed Jul 16, 2024
1 parent 2d5ec4f commit 8e2dbca
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/native/managed/cdacreader/tests/MethodTableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public unsafe class MethodTableTests
{ nameof(Data.MethodTable.ParentMethodTable), new () { Offset = 40, Type = DataType.pointer}},
{ nameof(Data.MethodTable.NumInterfaces), new () { Offset = 48, Type = DataType.uint16}},
{ nameof(Data.MethodTable.NumVirtuals), new () { Offset = 50, Type = DataType.uint16}},
{ nameof(Data.MethodTable.PerInstInfo), new () { Offset = 56, Type = DataType.pointer}},
}
};

Expand All @@ -33,6 +34,7 @@ public unsafe class MethodTableTests
{ nameof (Data.EEClass.MethodTable), new () { Offset = 8, Type = DataType.pointer}},
{ nameof (Data.EEClass.CorTypeAttr), new () { Offset = 16, Type = DataType.uint32}},
{ nameof (Data.EEClass.NumMethods), new () { Offset = 20, Type = DataType.uint16}},
{ nameof (Data.EEClass.InternalCorElementType), new () { Offset = 22, Type = DataType.uint8}},
}
};

Expand Down Expand Up @@ -150,7 +152,7 @@ public void HasRuntimeTypeSystemContract(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Contracts.MethodTableHandle handle = metadataContract.GetMethodTableHandle(TestFreeObjectMethodTableAddress);
Contracts.TypeHandle handle = metadataContract.GetTypeHandle(TestFreeObjectMethodTableAddress);
Assert.NotEqual(TargetPointer.Null, handle.Address);
Assert.True(metadataContract.IsFreeObjectMethodTable(handle));
});
Expand Down Expand Up @@ -187,9 +189,9 @@ public void ValidateSystemObjectMethodTable(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Contracts.MethodTableHandle systemObjectMethodTableHandle = metadataContract.GetMethodTableHandle(systemObjectMethodTablePtr);
Assert.Equal(systemObjectMethodTablePtr.Value, systemObjectMethodTableHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(systemObjectMethodTableHandle));
Contracts.TypeHandle systemObjectTypeHandle = metadataContract.GetTypeHandle(systemObjectMethodTablePtr);
Assert.Equal(systemObjectMethodTablePtr.Value, systemObjectTypeHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(systemObjectTypeHandle));
});
}

Expand Down Expand Up @@ -226,10 +228,10 @@ public void ValidateSystemStringMethodTable(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Contracts.MethodTableHandle systemStringMethodTableHandle = metadataContract.GetMethodTableHandle(systemStringMethodTablePtr);
Assert.Equal(systemStringMethodTablePtr.Value, systemStringMethodTableHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(systemStringMethodTableHandle));
Assert.True(metadataContract.IsString(systemStringMethodTableHandle));
Contracts.TypeHandle systemStringTypeHandle = metadataContract.GetTypeHandle(systemStringMethodTablePtr);
Assert.Equal(systemStringMethodTablePtr.Value, systemStringTypeHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(systemStringTypeHandle));
Assert.True(metadataContract.IsString(systemStringTypeHandle));
});
}

Expand Down Expand Up @@ -258,7 +260,7 @@ public void MethodTableEEClassInvalidThrows(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Assert.Throws<InvalidOperationException>(() => metadataContract.GetMethodTableHandle(badMethodTablePtr));
Assert.Throws<InvalidOperationException>(() => metadataContract.GetTypeHandle(badMethodTablePtr));
});
}

Expand Down Expand Up @@ -308,11 +310,11 @@ public void ValidateGenericInstMethodTable(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Contracts.MethodTableHandle genericInstanceMethodTableHandle = metadataContract.GetMethodTableHandle(genericInstanceMethodTablePtr);
Assert.Equal(genericInstanceMethodTablePtr.Value, genericInstanceMethodTableHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(genericInstanceMethodTableHandle));
Assert.False(metadataContract.IsString(genericInstanceMethodTableHandle));
Assert.Equal(numMethods, metadataContract.GetNumMethods(genericInstanceMethodTableHandle));
Contracts.TypeHandle genericInstanceTypeHandle = metadataContract.GetTypeHandle(genericInstanceMethodTablePtr);
Assert.Equal(genericInstanceMethodTablePtr.Value, genericInstanceTypeHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(genericInstanceTypeHandle));
Assert.False(metadataContract.IsString(genericInstanceTypeHandle));
Assert.Equal(numMethods, metadataContract.GetNumMethods(genericInstanceTypeHandle));
});
}

Expand Down Expand Up @@ -365,11 +367,11 @@ public void ValidateArrayInstMethodTable(MockTarget.Architecture arch)
{
Contracts.IRuntimeTypeSystem metadataContract = target.Contracts.RuntimeTypeSystem;
Assert.NotNull(metadataContract);
Contracts.MethodTableHandle arrayInstanceMethodTableHandle = metadataContract.GetMethodTableHandle(arrayInstanceMethodTablePtr);
Assert.Equal(arrayInstanceMethodTablePtr.Value, arrayInstanceMethodTableHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(arrayInstanceMethodTableHandle));
Assert.False(metadataContract.IsString(arrayInstanceMethodTableHandle));
Assert.Equal(arrayInstanceComponentSize, metadataContract.GetComponentSize(arrayInstanceMethodTableHandle));
Contracts.TypeHandle arrayInstanceTypeHandle = metadataContract.GetTypeHandle(arrayInstanceMethodTablePtr);
Assert.Equal(arrayInstanceMethodTablePtr.Value, arrayInstanceTypeHandle.Address.Value);
Assert.False(metadataContract.IsFreeObjectMethodTable(arrayInstanceTypeHandle));
Assert.False(metadataContract.IsString(arrayInstanceTypeHandle));
Assert.Equal(arrayInstanceComponentSize, metadataContract.GetComponentSize(arrayInstanceTypeHandle));
});

}
Expand Down

0 comments on commit 8e2dbca

Please sign in to comment.