Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-iter-10.cs
1 using System;
2 using System.Collections;
3
4 class X {
5         static IEnumerator GetIt
6         {
7             get {
8                 yield return 1;
9                 yield return 2;
10                 yield return 3;
11             }
12             set
13             {
14             }       
15         }
16         
17         IEnumerable this [int i]
18         {
19             get {
20                 yield return 1*i;
21                 yield return 2*i;
22                 yield return 3*i;
23             }
24             set
25             {
26             }
27         }
28
29         public static int Main ()
30         {
31                 IEnumerator e = GetIt;
32                 int total = 0;
33                 
34                 while (e.MoveNext ()){
35                         Console.WriteLine ("Value=" + e.Current);
36                         total += (int) e.Current;
37                 }
38
39                 if (total != 6)
40                         return 1;
41
42                 total = 0;
43                 X x = new X ();
44                 foreach (int i in x [2]){
45                         Console.WriteLine ("Value=" + i);
46                         total += i;
47                 }
48                 if (total != 12)
49                         return 2;
50                 
51                 return 0;
52         }
53 }