2 using System
.Collections
.Generic
;
4 // Generics mutate tests
6 class Disposable
<T
> : IDisposable
15 static Func
<T
[]> For
<T
> (List
<T
> list
)
19 for (int i
= 0; i
< t
.Length
; ++i
) {
27 static Func
<T
> Throw
<T
> (T t
)
31 throw new ApplicationException (l
.ToString ());
35 static Func
<T
> Do
<T
> (T t
)
42 } while (default (T
) != null);
48 static Func
<T
> Lock
<T
> (T t
)
60 static Func
<T
> Catch
<T
> (T t
)
65 throw new ApplicationException (l
.ToString ());
72 static Func
<T
> Finally
<T
> (T t
)
86 static Func
<T
> Using
<T
> (T t
)
89 using (var d
= new Disposable
<T
> ())
97 static Func
<T
> Switch
<T
> (T t
)
108 static Func
<List
<T
>> ForForeach
<T
> (T
[] t
)
112 return new List
<T
> () { e }
;
114 throw new ApplicationException ();
118 public void ArrayMutate
<T
> (T
[] array
)
121 Action
<int> anonMeth
= delegate (int slc
) {
122 long[] idx
= new long[] { 0, 0 }
;
123 for (int i
= 0; i
< r
; i
++) {
129 static Func
<T
[][]> ArrayMultiMutate
<T
> (T
[][] array
)
132 for (int i
= 0; i
< 3; i
++) {
133 array
[i
][i
] = default (T
);
140 public static int Main ()
142 if (For (new List
<int> { 5, 10 }
)() [1] != 10)
149 } catch (ApplicationException
)
165 var t6
= Finally (5);
169 var t7
= Using (1.1);
173 var t8
= Switch (55);
177 var t9
= ForForeach (new [] { 4, 1 }
);
181 var t10
= ArrayMultiMutate (new string [][] { new string [] { "a", "b", "c" }
, new string [] { "1", "2", "3" }
, new string [] { "A", "B", "C" }}
);
182 if (t10 () [2] [2] != null)
185 Console
.WriteLine ("OK");