Add exception rethrow tests.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Thu, 28 Oct 2021 09:18:03 +0000 (02:18 -0700)
committerAlexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Thu, 18 Nov 2021 15:31:44 +0000 (18:31 +0300)
test-suite/MITestExceptionBreakpoint/Program.cs
test-suite/VSCodeTestExceptionBreakpoint/Program.cs

index ce34572dbd2bc85a2102c57ff4d63266e1888f85..2c68b7339913e6f74602e63ec33665162d56157a 100644 (file)
@@ -352,11 +352,12 @@ namespace MITestExceptionBreakpoint
     {\r
         static void Main(string[] args)\r
         {\r
-            Label.Checkpoint("init", "test_throw_all", (Object context) => {\r
+            Label.Checkpoint("init", "test_rethrow", (Object context) => {\r
                 Context Context = (Context)context;\r
                 Context.Prepare(@"__FILE__:__LINE__");\r
                 Context.WasEntryPointHit(@"__FILE__:__LINE__");\r
 \r
+                Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_0");\r
                 Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_1");\r
                 Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_2");\r
                 Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_3");\r
@@ -378,7 +379,35 @@ namespace MITestExceptionBreakpoint
                 Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_19");\r
                 Context.EnableBreakpoint(@"__FILE__:__LINE__", "bp_test_20");\r
 \r
+                Context.Continue(@"__FILE__:__LINE__");\r
+            });\r
+\r
+            // test rethrow without any exception breakpoints setup\r
+\r
+            try {\r
+                try {\r
+                    new System.Exception();\r
+                } catch {\r
+                    throw;\r
+                }\r
+            } catch {}\r
+\r
+            try {\r
+                try {\r
+                    new System.Exception();\r
+                } catch {\r
+                    new System.NullReferenceException();\r
+                }\r
+            } catch {}\r
+\r
+            int test_rethrow = 0;                                                                  Label.Breakpoint("bp_test_0");\r
+\r
+            Label.Checkpoint("test_rethrow", "test_throw_all", (Object context) => {\r
+                Context Context = (Context)context;\r
+                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_0");\r
+\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "*");\r
+\r
                 Context.Continue(@"__FILE__:__LINE__");\r
             });\r
 \r
@@ -404,7 +433,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "21");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "22");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.NullReferenceException");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -435,7 +464,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException", "MITestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "22");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "23");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "*");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -476,7 +505,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_8");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "23");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "24");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "System.NullReferenceException");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -493,7 +522,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp4", "clr", "user-unhandled", "System.NullReferenceException");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "24");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "25");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "*");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -536,7 +565,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_15");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "25");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "26");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw+user-unhandled", "System.NullReferenceException");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -564,7 +593,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_17");\r
 \r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "26");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "27");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "*");\r
                 // Important! "unhandled" must be allowed too.\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "unhandled", "System.AppDomainUnloadedException System.Threading.ThreadAbortException");\r
@@ -577,11 +606,11 @@ namespace MITestExceptionBreakpoint
                 // Note, this is wrong setup for MDA that don't have "System.Exception", but in this way we test MDA/CLR category work.\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "--mda throw", "System.Exception");\r
                 // Delete only "System.Exception" from "throw" (previously had configured 4 breakpoints by one "throw" command).\r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "31");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "32");\r
                 // Check for breakpoint ID (test CalculateExceptionBreakpointHash() work), if we have 43 here -\r
                 // all breakpoint were created in proper way, no ID was reused (all breakpoint have unique hash at creation time).\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");\r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "43");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "44");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
             });\r
@@ -607,7 +636,7 @@ namespace MITestExceptionBreakpoint
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.Exception");\r
-                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "44");\r
+                Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "45");\r
 \r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasExceptionBreakpointHit(@"__FILE__:__LINE__", "bp3", "clr", "user-unhandled", "System.Exception");\r
index e9ea92f23df2e640debcec86cdd0d8029bdbe10a..586cc3b89ff8b5fe80116791e9779f8fb5e81010 100644 (file)
@@ -449,10 +449,11 @@ namespace VSCodeTestExceptionBreakpoint
     {\r
         static void Main(string[] args)\r
         {\r
-            Label.Checkpoint("init", "test_all", (Object context) => {\r
+            Label.Checkpoint("init", "test_rethrow", (Object context) => {\r
                 Context Context = (Context)context;\r
                 Context.PrepareStart(@"__FILE__:__LINE__");\r
 \r
+                Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_0");\r
                 Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_1");\r
                 Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_2");\r
                 Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_3");\r
@@ -472,12 +473,39 @@ namespace VSCodeTestExceptionBreakpoint
                 Context.AddBreakpoint(@"__FILE__:__LINE__", "bp_test_17");\r
                 Context.SetBreakpoints(@"__FILE__:__LINE__");\r
 \r
+                Context.PrepareEnd(@"__FILE__:__LINE__");\r
+                Context.WasEntryPointHit(@"__FILE__:__LINE__");\r
+                Context.Continue(@"__FILE__:__LINE__");\r
+            });\r
+\r
+            // test rethrow without any exception breakpoints setup\r
+\r
+            try {\r
+                try {\r
+                    new System.Exception();\r
+                } catch {\r
+                    throw;\r
+                }\r
+            } catch {}\r
+\r
+            try {\r
+                try {\r
+                    new System.Exception();\r
+                } catch {\r
+                    new System.NullReferenceException();\r
+                }\r
+            } catch {}\r
+\r
+            int test_rethrow = 0;                                                                  Label.Breakpoint("bp_test_0");\r
+\r
+            Label.Checkpoint("test_rethrow", "test_all", (Object context) => {\r
+                Context Context = (Context)context;\r
+                Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_0");\r
+\r
                 Context.ResetExceptionBreakpoints();\r
                 Context.AddExceptionBreakpointFilterAll();\r
                 Context.SetExceptionBreakpoints(@"__FILE__:__LINE__");\r
 \r
-                Context.PrepareEnd(@"__FILE__:__LINE__");\r
-                Context.WasEntryPointHit(@"__FILE__:__LINE__");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
             });\r
 \r