Merge pull request #1857 from slluis/fix-assembly-resolver
[mono.git] / mcs / class / corlib / Test / System.Runtime.ExceptionServices / ExceptionDispatchInfoTest.cs
index fb7d0e57f7c3d3a3801b30f20fe4df8787cf1ada..bef832b90c424aabe9d76f11943edbe7947d6671 100644 (file)
@@ -123,6 +123,34 @@ namespace MonoTests.System.Runtime.ExceptionServices
                                Assert.IsTrue (split [1].Contains ("---"), "#2");
                        }
                }
+
+               [Test]
+               public void ThrowMultipleCaptures ()
+               {
+                       Exception e;
+                       try {
+                               throw new Exception ("test");
+                       } catch (Exception e2) {
+                               e = e2;
+                       }
+
+                       var edi = ExceptionDispatchInfo.Capture (e);
+
+                       try {
+                               edi.Throw ();
+                       } catch (Exception e3) {
+                               edi = ExceptionDispatchInfo.Capture (e3);
+                       }
+
+                       try {
+                               edi.Throw ();
+                       } catch (Exception ex) {
+                               var split = ex.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
+                               Assert.AreEqual (7, split.Length, "#1");
+                               Assert.IsTrue (split [1].Contains ("---"), "#2");
+                               Assert.IsTrue (split [4].Contains ("---"), "#3");
+                       }
+               }               
        }
 }