From a3f1a33c39606faff49b9a965b725f13260bbb62 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 29 Nov 2019 09:22:18 -0800 Subject: [PATCH] Added some new tests --- IDE/Tests/Test1/scripts/Data01.txt | 9 +++++++++ IDE/Tests/Test1/src/Break.bf | 2 ++ IDE/Tests/Test1/src/Data01.bf | 29 +++++++++++++++++++++++++++++ IDE/Tests/Test1/src/Program.bf | 1 + IDEHelper/Tests/src/Reflection.bf | 23 +++++++++++++++++------ 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 IDE/Tests/Test1/scripts/Data01.txt create mode 100644 IDE/Tests/Test1/src/Data01.bf diff --git a/IDE/Tests/Test1/scripts/Data01.txt b/IDE/Tests/Test1/scripts/Data01.txt new file mode 100644 index 00000000..f4c9e851 --- /dev/null +++ b/IDE/Tests/Test1/scripts/Data01.txt @@ -0,0 +1,9 @@ +ShowFile("src/Data01.bf") +GotoText("//Test_End") +ToggleBreakpoint() +RunWithCompiling() + +AssertEvalEquals("sizeof(Derived)", "13") +AssertEvalEquals("strideof(Derived)", "16") +AssertEvalEquals("alignof(Derived)", "8") +AssertEvalEquals("iVal", "{ 123 }") \ No newline at end of file diff --git a/IDE/Tests/Test1/src/Break.bf b/IDE/Tests/Test1/src/Break.bf index ba6f1673..f4fd2adc 100644 --- a/IDE/Tests/Test1/src/Break.bf +++ b/IDE/Tests/Test1/src/Break.bf @@ -1,3 +1,5 @@ +#pragma warning disable 168 + using System.Threading; namespace IDETest diff --git a/IDE/Tests/Test1/src/Data01.bf b/IDE/Tests/Test1/src/Data01.bf new file mode 100644 index 00000000..ebee7d49 --- /dev/null +++ b/IDE/Tests/Test1/src/Data01.bf @@ -0,0 +1,29 @@ +using System; + +#pragma warning disable 168 + +namespace IDETest +{ + class Data01 + { + struct Base + { + int32 mA; + int64 mB; + } + + struct Derived : Base + { + int8 mC; + } + + public static void Test() + { + //Test_Start + Derived dr = .(); + Int iVal = (.)123; + + //Test_End + } + } +} diff --git a/IDE/Tests/Test1/src/Program.bf b/IDE/Tests/Test1/src/Program.bf index 8fa1a05e..6582c5b5 100644 --- a/IDE/Tests/Test1/src/Program.bf +++ b/IDE/Tests/Test1/src/Program.bf @@ -8,6 +8,7 @@ namespace IDETest Break.Test(); Breakpoints.Test(); Breakpoints02.Test(); + Data01.Test(); EnumTester.Test(); HotTester.Test(); HotSwap_BaseChange.Test(); diff --git a/IDEHelper/Tests/src/Reflection.bf b/IDEHelper/Tests/src/Reflection.bf index d47c0ca8..c5f4aadb 100644 --- a/IDEHelper/Tests/src/Reflection.bf +++ b/IDEHelper/Tests/src/Reflection.bf @@ -80,20 +80,21 @@ namespace Tests class ClassB { [AttrA(11, 22, "StrA", "StrB")] - int mA; + public int mA = 1; [AttrB(44, 55)] - int mB; - int mC; + public int mB = 2; + public int mC = 3; } [Reflect(.Type)] class ClassC { [AttrA(11, 22, "StrA", "StrC")] - int mA; + public int mA = 1; [AttrB(44, 55)] - int mB; - int mC; + public int mB = 2; + public int mC = 3; + public float mD = 4; } [Test] @@ -158,6 +159,16 @@ namespace Tests fieldIdx++; } + + let fieldInfo = cb.GetType().GetField("mC").Value; + int cVal = 0; + fieldInfo.GetValue(cb, out cVal); + fieldInfo.SetValue(cb, cVal + 1000); + Test.Assert(cb.mC == 1003); + + Variant variantVal = Variant.Create(123); + fieldInfo.SetValue(cb, variantVal); + Test.Assert(cb.mC == 123); } } }