1 // Compiler options: -langversion:future
4 using System.Threading;
5 using System.Threading.Tasks;
6 using System.Collections.Generic;
8 // Async stack spilling tests
23 public async Task<int> TestStack_1 (T t)
25 T[] a = new T[] { t };
26 return Call (t, a[0], out t,
27 await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
30 int Call (T t1, T t2, out T t3, int i)
54 int TestCall (ref int a, Type type, object o, ulong ul, int b)
58 if (type != typeof (string)) {
66 if (ul != ulong.MaxValue)
72 static async Task<int> TestStack_1 ()
75 var array = new ulong[] { ulong.MaxValue };
76 return new C ().TestCall (ref v, typeof (string), new S () { value = 4 }, array [0],
77 await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
80 int TestCall2<T1, T2, T3, T4, T5, T6, T7> (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
85 static async Task<int> TestStack_2 (ulong value)
88 return new C ().TestCall2 ((byte) 1, v, value = 9999, float.MaxValue, double.MaxValue, decimal.MaxValue,
89 await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
92 static async Task<int> TestStack_3 ()
94 var s = new S [] { new S () };
97 var s2 = new S [,] { { new S () }, { new S () } };
100 TestCall3 (ref s [0], ref s2 [0, 0], s [0].value++,
101 await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
103 if (s [0].value != 10)
106 if (s2 [0, 0].value != 20)
112 static int TestCall3 (ref S value, ref S value2, int value3, int i)
119 static async Task<int> TestStack_4 ()
121 var a1 = new [] { E.E_2 };
122 var a2 = new [] { new S () { value = 5 } };
123 var a3 = new [] { new C () };
125 return TestCall4 (a1[0], a2[0], a3[0],
126 await Task.Factory.StartNew (() => 3).ConfigureAwait (false));
129 static int TestCall4 (E e, S s, C c, int i)
143 static async Task<int> TestStack_5 ()
147 c.Prop += await Task.Factory.StartNew (() => {
148 if (c.get_called != 1)
153 }).ConfigureAwait (false);
155 if (c.get_called != 1)
158 if (c.prop_value != 109)
164 public static int Main ()
169 if (!Task.WaitAll (new[] { t }, 1000))
175 t = TestStack_2 (ulong.MaxValue);
176 if (!Task.WaitAll (new[] { t }, 1000))
183 if (!Task.WaitAll (new[] { t }, 1000))
190 if (!Task.WaitAll (new[] { t }, 1000))
196 var g = new G<sbyte> ();
197 t = g.TestStack_1 (9);
198 if (!Task.WaitAll (new[] { t }, 1000))
205 if (!Task.WaitAll (new[] { t }, 1000))
211 Console.WriteLine ("ok");