diff --git a/tests/TestArtifacts/TestComponent.d.ts b/tests/TestArtifacts/TestComponent.d.ts index ed5a12c..72920ce 100644 --- a/tests/TestArtifacts/TestComponent.d.ts +++ b/tests/TestArtifacts/TestComponent.d.ts @@ -58,6 +58,10 @@ declare namespace TestComponent { overloadedHierarchyBaseMethod(param1: string, param2: string): string; } + interface ISerializable { + serialize(): string; + } + type InterwovenDelegate = (inBool: boolean, inNumeric: number, inArray: number[]) => { outBool: boolean; outNumeric: number; outArray: number[]; fillArray: number[]; returnValue: number }; type NumericArrayDelegate = (values: number[]) => { subset: number[]; outValue: number[]; returnValue: number[] }; @@ -450,9 +454,11 @@ declare namespace TestComponent { fourth, } - class TestObject { + class TestObject implements TestComponent.ISerializable { readonly value: number; constructor(val: number); + asSerializable(): TestComponent.ISerializable; + serialize(): string; } } \ No newline at end of file diff --git a/tests/WinRTTests/BasicFunctionTests.js b/tests/WinRTTests/BasicFunctionTests.js index a251f74..78e5c81 100644 --- a/tests/WinRTTests/BasicFunctionTests.js +++ b/tests/WinRTTests/BasicFunctionTests.js @@ -81,6 +81,8 @@ export function makeBasicFunctionTestScenarios(pThis) { //Static methods for non activable classes new TestScenario('StaticOnlyTest::CopyString', runStaticMethodForNonActivableMethod.bind(pThis)), + + new TestScenario('Object Identity', runObjectIdentityTest.bind(pThis)), ]; } @@ -672,4 +674,12 @@ function runStaticMethodForNonActivableMethod(scenario) { this.runSync(scenario, () => { assert.equal("Hello", TestComponent.StaticOnlyTest.copyString("Hello")); }); +} + +function runObjectIdentityTest(scenario) { + this.runSync(scenario, () => { + const testObject = new TestComponent.TestObject(2); + const testObjectAsSerializable = testObject.asSerializable(); + assert.isTrue(testObject === testObjectAsSerializable); + }); } \ No newline at end of file diff --git a/tests/WinRTTests/windows/TestComponent/Test.h b/tests/WinRTTests/windows/TestComponent/Test.h index 60d18b8..09c3a25 100644 --- a/tests/WinRTTests/windows/TestComponent/Test.h +++ b/tests/WinRTTests/windows/TestComponent/Test.h @@ -16,6 +16,16 @@ namespace winrt::TestComponent::implementation return m_value; } + winrt::hstring Serialize() + { + return L"TestObject:::" + winrt::to_hstring(m_value); + } + + ISerializable AsSerializable() + { + return *this; + } + private: int32_t m_value; }; diff --git a/tests/WinRTTests/windows/TestComponent/TestComponent.idl b/tests/WinRTTests/windows/TestComponent/TestComponent.idl index 09593aa..3662271 100644 --- a/tests/WinRTTests/windows/TestComponent/TestComponent.idl +++ b/tests/WinRTTests/windows/TestComponent/TestComponent.idl @@ -59,14 +59,22 @@ namespace TestComponent BooleanTypes Bools; }; + [contract(TestContract, 1)] + interface ISerializable + { + String Serialize(); + }; + // Used in places where we want to validate returning/accepting/etc. types of an object type [contract(TestContract, 1)] - runtimeclass TestObject + runtimeclass TestObject : ISerializable { // This is purposefully not no-arg constructible so that we get compilation errors if the code gen gets this wrong TestObject(Int32 val); Int32 Value{ get; }; + + ISerializable AsSerializable(); } // Delegates