2010-05-31 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-iter-01.cs
blob04a52b53fe507619bbcf6a8095c9836ea935e315
1 // Compiler options: -langversion:default
3 using System;
4 using System.Collections;
6 class X {
7 static IEnumerator GetIt ()
9 yield return 1;
10 yield return 2;
11 yield return 3;
14 static IEnumerable GetIt2 ()
16 yield return 1;
17 yield return 2;
18 yield return 3;
21 static int Main ()
23 IEnumerator e = GetIt ();
24 int total = 0;
26 while (e.MoveNext ()){
27 Console.WriteLine ("Value=" + e.Current);
28 total += (int) e.Current;
31 if (total != 6)
32 return 1;
34 total = 0;
35 foreach (int i in GetIt2 ()){
36 Console.WriteLine ("Value=" + i);
37 total += i;
39 if (total != 6)
40 return 2;
42 return 0;