Merge pull request #901 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / tests / test-async-22.cs
index d8cd87bd359b65911a2a1c0bd4b01d3b744da286..c9824a794e22d1c803eadb0028dd5c8a42017053 100644 (file)
@@ -1,11 +1,8 @@
-// Compiler options: -langversion:future
-
 using System;
 using System.Threading.Tasks;
 
-// contextual async during parsing
-
-class A
+// contextual async, parser tests
+class A : Iasync
 {
        async Task<int> async ()
        {
@@ -17,6 +14,16 @@ class A
        {
                throw new NotImplementedException ();
        }
+       
+       async void CastTest ()
+       {
+               var res = (int) await async ();
+               var res2 = (Int32) await async ();
+       }
+       
+       async void Iasync.async ()
+       {
+       }
 
        public static int Main ()
        {
@@ -24,6 +31,11 @@ class A
        }
 }
 
+interface Iasync
+{
+       void async ();
+}
+
 class B
 {
        class async
@@ -34,6 +46,29 @@ class B
        }
 }
 
+class C
+{
+       static void Test (bool async)
+       {
+               var a = async ? Prop : 2;
+       }
+
+       static int Prop {
+               get {
+                       return 3;
+               }
+       }
+}
+
+class D
+{
+       enum E {}
+
+       async Task M ()
+       {
+       }
+}
+
 class async
 {
        async (async arg)
@@ -53,4 +88,81 @@ class await
 class asyncAttribute: Attribute
 {
        delegate async async (async async);
-}
\ No newline at end of file
+}
+
+namespace AsyncNS
+{
+       class Classes
+       {
+               class async
+               {
+               }
+               
+               void M ()
+               {
+                       async local;
+               }
+       }
+
+       namespace Namespaces
+       {
+               namespace async { }
+       }
+}
+
+namespace AwaitNS
+{
+       class Formals
+       {
+               delegate void D (int x);
+               static void M1 ()
+               {
+                       D d1 = await => { };
+                       D d2 = (int await) => { };
+                       D d3 = delegate (int await) { };
+               }
+       }
+
+       class Methods
+       {
+               void await () { }
+               void M (Methods m)
+               {
+                       m.await ();
+                       this.await ();
+                       // FIXME: await ();
+               }
+       }
+
+       class Classes
+       {
+               class await { }
+               void M ()
+               {
+                       // FIXME: @await local = new @await ();
+               }
+       }
+
+       class AnonTypes
+       {
+               static void M ()
+               {
+                       var x = new { await = 1 };
+                       var y = x.await;
+                       int await = 2;
+                       var x2 = new { await };
+               }
+       }
+
+       class Initializer
+       {
+               int await;
+
+               static void M ()
+               {
+                       var a = new Initializer () {
+                               await = 2
+                       };
+               }
+       }
+}