summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAaron Robinson <arobins@microsoft.com>2019-03-08 17:36:37 -0800
committerGitHub <noreply@github.com>2019-03-08 17:36:37 -0800
commitc194074a82ee35f31b1e55233b43256713b26467 (patch)
tree3a619035253d8ebfba896210adc5f1c030d3abef /tests
parentee56e5874db8780c99d2d93169aacf477f7b73f1 (diff)
downloadcoreclr-c194074a82ee35f31b1e55233b43256713b26467.tar.gz
coreclr-c194074a82ee35f31b1e55233b43256713b26467.tar.bz2
coreclr-c194074a82ee35f31b1e55233b43256713b26467.zip
Properly override IsEquivalentTo() API in RuntimeType (#23137)
* Properly override IsEquivalentTo() API in RuntimeType * Add tests for API validation
Diffstat (limited to 'tests')
-rw-r--r--tests/src/baseservices/typeequivalence/simple/Simple.cs31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/src/baseservices/typeequivalence/simple/Simple.cs b/tests/src/baseservices/typeequivalence/simple/Simple.cs
index 0b6a54d14c..56c3ecd3fa 100644
--- a/tests/src/baseservices/typeequivalence/simple/Simple.cs
+++ b/tests/src/baseservices/typeequivalence/simple/Simple.cs
@@ -38,6 +38,34 @@ public class Simple
}
}
+ private static void ValidateTypeInstanceEquality()
+ {
+ Console.WriteLine($"{nameof(ValidateTypeInstanceEquality)}");
+ var inAsm = EmptyType.Create();
+ var otherAsm = EmptyType2.Create();
+
+ Type inAsmInterfaceType = inAsm.GetType().GetInterface(nameof(IEmptyType));
+ Type otherAsmInterfaceType = otherAsm.GetType().GetInterface(nameof(IEmptyType));
+
+ // Sanity checks
+ Assert.IsTrue(inAsmInterfaceType == inAsmInterfaceType);
+ Assert.IsTrue(inAsmInterfaceType.IsEquivalentTo(inAsmInterfaceType));
+ Assert.IsFalse(inAsmInterfaceType.IsEquivalentTo(inAsm.GetType()));
+ Assert.IsTrue(otherAsmInterfaceType == otherAsmInterfaceType);
+ Assert.IsTrue(otherAsmInterfaceType.IsEquivalentTo(otherAsmInterfaceType));
+ Assert.IsFalse(otherAsmInterfaceType.IsEquivalentTo(otherAsm.GetType()));
+
+ // The intrinsic equality operations should fail
+ Assert.IsFalse(inAsmInterfaceType == otherAsmInterfaceType);
+ Assert.IsFalse(inAsmInterfaceType.Equals(otherAsmInterfaceType));
+ Assert.IsFalse(otherAsmInterfaceType == inAsmInterfaceType);
+ Assert.IsFalse(otherAsmInterfaceType.Equals(inAsmInterfaceType));
+
+ // Determination of equal types requires API call
+ Assert.IsTrue(inAsmInterfaceType.IsEquivalentTo(otherAsmInterfaceType));
+ Assert.IsTrue(otherAsmInterfaceType.IsEquivalentTo(inAsmInterfaceType));
+ }
+
private class MethodTestDerived : MethodTestBase
{
private readonly int scaleValue;
@@ -127,6 +155,7 @@ public class Simple
try
{
InterfaceTypesFromDifferentAssembliesAreEquivalent();
+ ValidateTypeInstanceEquality();
InterfaceTypesMethodOperations();
CallSparseInterface();
}
@@ -138,4 +167,4 @@ public class Simple
return 100;
}
-} \ No newline at end of file
+}