2 using System
.Threading
;
3 using System
.Threading
.Tasks
;
4 using System
.Collections
.Generic
;
6 // Async stack spilling tests
21 public async Task
<int> TestStack_1 (T t
)
23 T
[] a
= new T
[] { t }
;
24 return Call (t
, a
[0], out t
,
25 await Task
.Factory
.StartNew (() => 3).ConfigureAwait (false));
28 int Call (T t1
, T t2
, out T t3
, int i
)
52 int TestCall (ref int a
, Type type
, object o
, ulong ul
, int b
)
56 if (type
!= typeof (string)) {
64 if (ul
!= ulong.MaxValue
)
70 static async Task
<int> TestStack_1 ()
73 var array
= new ulong[] { ulong.MaxValue }
;
74 return new C ().TestCall (ref v
, typeof (string), new S () { value = 4 }
, array
[0],
75 await Task
.Factory
.StartNew (() => 3).ConfigureAwait (false));
78 int TestCall2
<T1
, T2
, T3
, T4
, T5
, T6
, T7
> (T1 t1
, T2 t2
, T3 t3
, T4 t4
, T5 t5
, T6 t6
, T7 t7
)
83 static async Task
<int> TestStack_2 (ulong value)
86 return new C ().TestCall2 ((byte) 1, v
, value = 9999, float.MaxValue
, double.MaxValue
, decimal.MaxValue
,
87 await Task
.Factory
.StartNew (() => 3).ConfigureAwait (false));
90 static async Task
<int> TestStack_3 ()
92 var s
= new S
[] { new S () }
;
95 var s2
= new S
[,] { { new S () }
, { new S () }
};
98 TestCall3 (ref s
[0], ref s2
[0, 0], s
[0].value++,
99 await Task
.Factory
.StartNew (() => 3).ConfigureAwait (false));
101 if (s
[0].value != 10)
104 if (s2
[0, 0].value != 20)
110 static int TestCall3 (ref S
value, ref S value2
, int value3
, int i
)
117 static async Task
<int> TestStack_4 ()
119 var a1
= new [] { E.E_2 }
;
120 var a2
= new [] { new S () { value = 5 }
};
121 var a3
= new [] { new C () }
;
123 return TestCall4 (a1
[0], a2
[0], a3
[0],
124 await Task
.Factory
.StartNew (() => 3).ConfigureAwait (false));
127 static int TestCall4 (E e
, S s
, C c
, int i
)
141 static async Task
<int> TestStack_5 ()
145 c
.Prop
+= await Task
.Factory
.StartNew (() => {
146 if (c
.get_called
!= 1)
151 }).ConfigureAwait (false);
153 if (c
.get_called
!= 1)
156 if (c
.prop_value
!= 109)
162 public static int Main ()
167 if (!Task
.WaitAll (new[] { t }
, 1000))
173 t
= TestStack_2 (ulong.MaxValue
);
174 if (!Task
.WaitAll (new[] { t }
, 1000))
181 if (!Task
.WaitAll (new[] { t }
, 1000))
188 if (!Task
.WaitAll (new[] { t }
, 1000))
194 var g
= new G
<sbyte> ();
195 t
= g
.TestStack_1 (9);
196 if (!Task
.WaitAll (new[] { t }
, 1000))
203 if (!Task
.WaitAll (new[] { t }
, 1000))
209 Console
.WriteLine ("ok");