Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / test-async-11.cs
index 543985e49dfe3507fea3395244d50ed2a3b770d5..11a02cb83ddcf3e5a10cdedc91be6959e15f1e21 100644 (file)
@@ -1,5 +1,3 @@
-// Compiler options: -langversion:future
-
 using System;
 using System.Threading;
 using System.Threading.Tasks;
@@ -24,7 +22,7 @@ class G<T>
        {
                T[] a = new T[] { t };
                return Call (t, a[0], out t,
-                       await Task.Factory.StartNew (() => 3));
+                       await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
        }
        
        int Call (T t1, T t2, out T t3, int i)
@@ -39,8 +37,11 @@ class C
        int field;
        
        int prop_value;
+       int get_called;
+       
        int Prop {
                get {
+                       ++get_called;
                        return prop_value;
                }
                set {
@@ -71,7 +72,7 @@ class C
                int v = 9;
                var array = new ulong[] { ulong.MaxValue };
                return new C ().TestCall (ref v, typeof (string), new S () { value = 4 }, array [0],
-                       await Task.Factory.StartNew (() => 3));
+                       await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
        }
 
        int TestCall2<T1, T2, T3, T4, T5, T6, T7> (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
@@ -83,7 +84,7 @@ class C
        {
                short v = 2;
                return new C ().TestCall2 ((byte) 1, v, value = 9999, float.MaxValue, double.MaxValue, decimal.MaxValue,
-                       await Task.Factory.StartNew (() => 3));
+                       await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
        }
 
        static async Task<int> TestStack_3 ()
@@ -95,13 +96,13 @@ class C
                s2[0, 0].value = 3;
                
                TestCall3 (ref s [0], ref s2 [0, 0], s [0].value++,
-                       await Task.Factory.StartNew (() => 3));
+                       await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
                
                if (s [0].value != 10)
                        return 1;
                
                if (s2 [0, 0].value != 20)
-                       return 1;
+                       return 2;
 
                return 0;
        }
@@ -120,7 +121,7 @@ class C
                var a3 = new [] { new C () };
                
                return TestCall4 (a1[0], a2[0], a3[0],
-                       await Task.Factory.StartNew (() => 3));
+                       await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
        }
        
        static int TestCall4 (E e, S s, C c, int i)
@@ -141,10 +142,19 @@ class C
        {
                var c = new C ();
                c.prop_value = 7;
-               c.Prop += await Task.Factory.StartNew (() => { c.prop_value = 99; return 3; });
+               c.Prop += await Task.Factory.StartNew (() => {
+                       if (c.get_called != 1) 
+                               return -44;
+                       
+                       c.prop_value = 99;
+                       return 3;
+               }).ConfigureAwait (false);
                
-               if (c.prop_value != 10)
+               if (c.get_called != 1)
                        return 1;
+               
+               if (c.prop_value != 109)
+                       return 2;
 
                return 0;
        }