Add MI/GDB and VSCode tests for eval with exception.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Wed, 20 May 2020 10:42:59 +0000 (13:42 +0300)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 21 May 2020 21:27:05 +0000 (06:27 +0900)
test-suite/MITestSetValue/Program.cs
test-suite/VSCodeTestVariables/Program.cs

index b4a0ae5503074531f55f615254dd15e44d9d3b41..42f4e709b1f29981797db260c4172ecb7126e826 100644 (file)
@@ -322,6 +322,49 @@ namespace MITestSetValue
         }
     }
 
+    public struct TestStruct7
+    {
+        public int val1
+        {
+            get
+            {
+                return 567; 
+            }
+        }
+
+        public int val2
+        {
+            get
+            {
+                try {
+                    throw new System.DivideByZeroException();
+                }
+                catch
+                {
+                    return 777; 
+                }
+                return 888; 
+            }
+        }
+
+        public int val3
+        {
+            get
+            {
+                throw new System.DivideByZeroException();
+                return 777; 
+            }
+        }
+
+        public string val4
+        {
+            get
+            {
+                return "text_567"; 
+            }
+        }
+    }
+
     class Program
     {
         static void Main(string[] args)
@@ -343,9 +386,10 @@ namespace MITestSetValue
                 Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK4"], 7);
                 Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK5"], 8);
                 Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK6"], 9);
+                Context.InsertBreakpoint(DebuggeeInfo.Breakpoints["BREAK7"], 10);
 
                 Assert.Equal(MIResultClass.Running,
-                             Context.MIDebugger.Request("10-exec-continue").Class);
+                             Context.MIDebugger.Request("11-exec-continue").Class);
             });
 
             TestStruct2 ts = new TestStruct2(1, 5, 10);
@@ -465,7 +509,7 @@ namespace MITestSetValue
 
             int dummy6 = 6;                                     Label.Breakpoint("BREAK6");
 
-            Label.Checkpoint("test_eval_timeout", "finish", () => {
+            Label.Checkpoint("test_eval_timeout", "test_eval_with_exception", () => {
                 Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK6"]);
 
                 var task = System.Threading.Tasks.Task.Run(() => 
@@ -482,6 +526,22 @@ namespace MITestSetValue
                              Context.MIDebugger.Request("-exec-continue").Class);
             });
 
+            TestStruct7 ts7 = new TestStruct7();
+
+            int dummy7 = 7;                                     Label.Breakpoint("BREAK7");
+
+            Label.Checkpoint("test_eval_with_exception", "finish", () => {
+                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["BREAK7"]);
+
+                Assert.Equal("567", Context.GetChildValue("ts7", 0, false, 0));
+                Assert.Equal("777", Context.GetChildValue("ts7", 1, false, 0));
+                Assert.Equal("{System.DivideByZeroException}", Context.GetChildValue("ts7", 2, false, 0));
+                Assert.Equal("\\\"text_567\\\"", Context.GetChildValue("ts7", 3, false, 0));
+
+                Assert.Equal(MIResultClass.Running,
+                             Context.MIDebugger.Request("-exec-continue").Class);
+            });
+
             Label.Checkpoint("finish", "", () => {
                 Context.WasExit();
                 Context.DebuggerExit();
index 318454f1a88330735bc7637d7515877957aaf43a..b10a6079311d2f4ed63b5cda59d33bd40af168de 100644 (file)
@@ -321,6 +321,7 @@ namespace VSCodeTestVariables
                 Context.AddBreakpoint("bp2");
                 Context.AddBreakpoint("bp3");
                 Context.AddBreakpoint("bp4");
+                Context.AddBreakpoint("bp5");
                 Context.AddBreakpoint("bp_func");
                 Context.SetBreakpoints();
                 Context.PrepareEnd();
@@ -337,7 +338,7 @@ namespace VSCodeTestVariables
             Label.Checkpoint("bp_test", "bp_func_test", () => {
                 Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["bp"]);
                 Int64 frameId = Context.DetectFrameId(DebuggeeInfo.Breakpoints["bp"]);
-                Context.CheckVariablesCount(frameId, "Locals", 6);
+                Context.CheckVariablesCount(frameId, "Locals", 7);
                 int variablesReference = Context.GetVariablesReference(frameId, "Locals");
                 Context.EvalVariable(variablesReference, "string[]", "args" , "{string[0]}");
                 Context.EvalVariable(variablesReference, "int", "i", "2");
@@ -405,7 +406,7 @@ namespace VSCodeTestVariables
 
             i++;                                                            Label.Breakpoint("bp4");
 
-            Label.Checkpoint("test_eval_timeout", "finish", () => {
+            Label.Checkpoint("test_eval_timeout", "test_eval_exception", () => {
                 Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["bp4"]);
                 Int64 frameId = Context.DetectFrameId(DebuggeeInfo.Breakpoints["bp4"]);
 
@@ -435,6 +436,30 @@ namespace VSCodeTestVariables
                 Context.Continue();
             });
 
+            TestStruct7 ts7 = new TestStruct7();
+
+            i++;                                                            Label.Breakpoint("bp5");
+
+            Label.Checkpoint("test_eval_exception", "finish", () => {
+                Context.WasBreakpointHit(DebuggeeInfo.Breakpoints["bp5"]);
+                Int64 frameId = Context.DetectFrameId(DebuggeeInfo.Breakpoints["bp5"]);
+
+                int variablesReference_Locals = Context.GetVariablesReference(frameId, "Locals");
+                int variablesReference_ts7 = Context.GetChildVariablesReference(variablesReference_Locals, "ts7");
+
+                Context.EvalVariable(variablesReference_ts7, "int", "val1", "567");
+                Context.EvalVariable(variablesReference_ts7, "int", "val2", "777");
+                Context.EvalVariable(variablesReference_ts7, "System.DivideByZeroException", "val3", "{System.DivideByZeroException}");
+                Context.EvalVariable(variablesReference_ts7, "string", "val4", "\"text_567\"");
+
+                Context.EvalVariableByIndex(variablesReference_ts7, "int", 0, "567");
+                Context.EvalVariableByIndex(variablesReference_ts7, "int", 1, "777");
+                Context.EvalVariableByIndex(variablesReference_ts7, "System.DivideByZeroException", 2, "{System.DivideByZeroException}");
+                Context.EvalVariableByIndex(variablesReference_ts7, "string", 3, "\"text_567\"");
+
+                Context.Continue();
+            });
+
             Label.Checkpoint("finish", "", () => {
                 Context.WasExit();
                 Context.DebuggerExit();
@@ -558,5 +583,48 @@ namespace VSCodeTestVariables
                 }
             }
         }
+
+        public struct TestStruct7
+        {
+            public int val1
+            {
+                get
+                {
+                    return 567; 
+                }
+            }
+
+            public int val2
+            {
+                get
+                {
+                    try {
+                        throw new System.DivideByZeroException();
+                    }
+                    catch
+                    {
+                        return 777; 
+                    }
+                    return 888; 
+                }
+            }
+
+            public int val3
+            {
+                get
+                {
+                    throw new System.DivideByZeroException();
+                    return 777; 
+                }
+            }
+
+            public string val4
+            {
+                get
+                {
+                    return "text_567"; 
+                }
+            }
+        }
     }
 }