[w32file] Move MonoIO.Find{First,Next,Close} to managed
[mono.git] / mcs / tests / gtest-iter-23.cs
1 using System;
2 using System.Collections.Generic;
3
4 class C
5 {
6         static IEnumerable<int> Test ()
7         {
8                 List<Func<int>> lambdas = new List<Func<int>> ();
9                 for (int i = 0; i < 4; ++i) {
10                         int h = i;
11                         lambdas.Add (() => h);
12                         yield return 2;
13                 }
14
15                 for (int i = 0; i < 4; ++i) {
16                         yield return lambdas[i] ();
17                 }
18         }
19
20         static IEnumerable<int> Test_2 ()
21         {
22                 List<Func<int>> lambdas = new List<Func<int>> ();
23                 for (int i = 0; i < 4; ++i) {
24                         int h = i;
25                         lambdas.Add (() => h);
26                 }
27
28                 for (int i = 0; i < 4; ++i) {
29                         yield return lambdas[i] ();
30                 }
31         }
32
33         public static int Main ()
34         {
35                 int t = 0;
36                 foreach (var a in Test ()) {
37                         t += a;
38                 }
39
40                 Console.WriteLine (t);
41                 if (t != 14)
42                         return 1;
43
44                 t = 0;
45                 foreach (var a in Test_2 ()) {
46                         t += a;
47                 }
48
49                 Console.WriteLine (t);
50                 if (t != 6)
51                         return 2;
52
53                 return 0;
54         }
55 }