[wasm][debugger] Create test Inherited Properties (#56754)
authorThays Grazia <thaystg@gmail.com>
Tue, 3 Aug 2021 16:56:08 +0000 (13:56 -0300)
committerGitHub <noreply@github.com>
Tue, 3 Aug 2021 16:56:08 +0000 (11:56 -0500)
* Created test case do close 47658.

* Moving test to file that @radical suggested.

src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs
src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs

index 3215ef1..6b4dcd6 100644 (file)
@@ -335,6 +335,32 @@ namespace DebuggerTests
             AssertEqual(expected_names.Length, filtered_props.Count(), $"expected number of properties");
         }
 
+        [Fact]
+        public async Task GetObjectValueWithInheritance()
+        {
+            var pause_location = await EvaluateAndCheck(
+               "window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);",
+                "dotnet://debugger-test.dll/debugger-test2.cs", 83, 4,
+               "TestWatchWithInheritance");
+            var frame_id = pause_location["callFrames"][0]["callFrameId"].Value<string>();
+            var frame_locals = await GetProperties(frame_id);
+            var test_props = await GetObjectOnLocals(frame_locals, "test");
+            await CheckProps(test_props, new
+            {
+                j = TNumber(20),
+                i = TNumber(50),
+                k = TNumber(30),
+                GetJ = TGetter("GetJ"),
+                GetI = TGetter("GetI"),
+                GetK = TGetter("GetK")
+            }, "test_props");
+            await EvaluateOnCallFrameAndCheck(frame_id,
+                ($"test.GetJ", TNumber(20)),
+                ($"test.GetI", TNumber(50)),
+                ($"test.GetK", TNumber(30))
+            );
+        }
+
         private async Task CheckExpectedProperties(string[] expected_names, Func<string, JToken> get_actual_prop, Dictionary<string, (JObject, bool)> all_props)
         {
             foreach (var exp_name in expected_names)
index b9d97c8..d360819 100644 (file)
@@ -56,3 +56,30 @@ public class UserBreak {
         Debugger.Break();
     }
 }
+
+public class TestParent2
+{
+    public int k = 30;
+    public int GetK => k;
+}
+
+public class TestParent : TestParent2
+{
+    public int j = 20;
+    public int GetJ => j;
+}
+
+public class TestChild : TestParent
+{
+    public int i = 50;
+    public int GetI => i;
+    public TestChild()
+    {
+        Console.WriteLine("Hi");
+    }
+    public static void TestWatchWithInheritance()
+    {
+        TestChild test = new TestChild();
+        Debugger.Break();
+    }
+}