Merge pull request #3528 from BrzVlad/fix-sgen-check-before-collections
[mono.git] / mcs / class / corlib / Test / System.Runtime.CompilerServices / TaskAwaiterTest_T.cs
index 6ea7651e07918275347808ed9184e8478650e246..867a06cabc57031a5ac00b9017a0f23d4d6605ab 100644 (file)
@@ -26,7 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_4_5
 
 using System;
 using System.Threading;
@@ -88,18 +87,34 @@ namespace MonoTests.System.Runtime.CompilerServices
                        }
                }
 
+               [Category ("NotWorking")] // Bug #18629
                [Test]
-               public void GetResultNotCompleted ()
+               public void GetResultAfterMultipleExceptions ()
                {
-                       TaskAwaiter<int> awaiter;
+                       TaskAwaiter<object> awaiter;
+                       CreateFaultedAwaiter (out awaiter);
+                       try {
+                               awaiter.GetResult ();
+                               Assert.Fail ();
+                       } catch (AggregateException ae) {
+                               Assert.IsFalse (ae.StackTrace.Contains ("--- End"), "#1");
+                               Assert.IsTrue (ae.StackTrace.Contains ("CreateFaultedAwaiter"), "#2");
+                       }
+               }
 
-                       task = new Task<int> (() => 1);
-                       awaiter = task.GetAwaiter ();
+               static void CreateFaultedAwaiter (out TaskAwaiter<object> awaiter)
+               {
+                       var faultedSource = new TaskCompletionSource<object>();
+                       faultedSource.SetException(new Exception());
+                       awaiter = faultedSource.Task.GetAwaiter ();
+                       try {
+                               awaiter.GetResult ();
+                       } catch {
+                       }
 
                        try {
                                awaiter.GetResult ();
-                               Assert.Fail ();
-                       } catch (InvalidOperationException) {
+                       } catch {
                        }
                }
 
@@ -157,4 +172,3 @@ namespace MonoTests.System.Runtime.CompilerServices
        }
 }
 
-#endif
\ No newline at end of file