diff --git a/IDEHelper/Tests/src/Boxing.bf b/IDEHelper/Tests/src/Boxing.bf index 7e3dbc6e..d984c001 100644 --- a/IDEHelper/Tests/src/Boxing.bf +++ b/IDEHelper/Tests/src/Boxing.bf @@ -22,6 +22,7 @@ namespace Tests } } + [Reflect(.DynamicBoxing)] struct StructB : StructA, IHashable { public int mB = 200; @@ -60,12 +61,31 @@ namespace Tests Test.Assert(GetFromIFace(iface1) == 2100); Test.Assert(valB.mA == 1100); // This should copy values + StructC valC = .(); + var boxedVal = scope box valA; iface0 = boxedVal; #unwarn var boxedStr = scope box "Test"; IHashable ihash = boxedStr; + + Variant saVariant = .Create(valA); + var saObj = saVariant.GetBoxed().Value; + delete saObj; + saVariant.Dispose(); + + Variant sbVariant = .Create(valB); + var scObj = sbVariant.GetBoxed().Value; + IHashable ih = scObj; + Test.Assert(ih.GetHashCode() == 200); + delete scObj; + sbVariant.Dispose(); + + Variant scVariant = .Create(valC); + var scObjResult = scVariant.GetBoxed(); + Test.Assert(scObjResult case .Err); + scVariant.Dispose(); } [Test] diff --git a/IDEHelper/Tests/src/Reflection.bf b/IDEHelper/Tests/src/Reflection.bf index fc1e4336..85ccaa1a 100644 --- a/IDEHelper/Tests/src/Reflection.bf +++ b/IDEHelper/Tests/src/Reflection.bf @@ -108,7 +108,14 @@ namespace Tests } [Reflect, AlwaysInclude(IncludeAllMethods=true)] - struct StructA + interface IFaceA + { + void MethodA0(); + int MethodA1(int a, float b); + } + + [Reflect, AlwaysInclude(IncludeAllMethods=true)] + struct StructA : IFaceA { public int mA; public int mB; @@ -123,6 +130,16 @@ namespace Tests mB += a; return a + mA * 100; } + + public void MethodA0() + { + + } + + public int MethodA1(int a, float b) + { + return mA + a + (int)b; + } } struct StructC @@ -473,10 +490,14 @@ namespace Tests result.Dispose(); case 2: - Test.Assert(methodInfo.Name == "__BfCtor"); + Test.Assert(methodInfo.Name == "MethodA0"); case 3: - Test.Assert(methodInfo.Name == "__Equals"); + Test.Assert(methodInfo.Name == "MethodA1"); case 4: + Test.Assert(methodInfo.Name == "__BfCtor"); + case 5: + Test.Assert(methodInfo.Name == "__Equals"); + case 6: Test.Assert(methodInfo.Name == "__StrictEquals"); default: Test.FatalError(); // Shouldn't have any more @@ -484,6 +505,15 @@ namespace Tests methodIdx++; } + + let ifaceType = typeof(IFaceA); + let methodA1 = ifaceType.GetMethod("MethodA1").Value; + var saVariant = Variant.Create(sa); + defer saVariant.Dispose(); + var result = methodA1.Invoke(saVariant, .Create(1000), .Create(2000.f)).Value; + Test.Assert(result.Get() == 3012); + result = methodA1.Invoke(.Create(&sa), .Create(1000), .Create(2000.f)).Value; + Test.Assert(result.Get() == 3012); } [Test]