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 public static int Main ()
131 if (For (new List<int> { 5, 10 })() [1] != 10)
138 } catch (ApplicationException)
154 var t6 = Finally (5);
158 var t7 = Using (1.1);
162 var t8 = Switch (55);
166 var t9 = ForForeach (new [] { 4, 1 });
170 Console.WriteLine ("OK");