2005-06-13 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / tests / 2test-16.cs
1 using System;
2 using System.Collections;
3
4 public class Tester
5 {
6         string[] ABC = { "A", "B", "C" };
7         // D
8         string [,] EFGH = { { "E", "F" }, { "G", "H"}};
9         // I
10         ArrayList al = new ArrayList ();
11         
12         public Tester ()
13         {
14                 al.Add ("J");
15                 al.Add ("K");
16         }
17         
18         public System.Collections.IEnumerator GetEnumerator()
19         {
20                 foreach (string s in ABC){
21                         if (s == null)
22                                 throw new Exception ();
23                         else
24                                 yield return s;
25                 }
26                 
27                 yield return "D";
28                 foreach (string s in EFGH){
29                         if(s == null)
30                                 throw new Exception ();
31                         else
32                                 yield return s;
33                 }
34                 
35                 yield return "I";
36                 foreach (string s in al){
37                         if (s == null)
38                                 throw new Exception ();
39                         else
40                                 yield return s;
41                 }
42                 
43                 yield return "L";
44         }
45 }
46
47
48 class Test
49 {
50         public static int Main()
51         {
52                 Tester tester = new Tester();
53                 string [] list = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" };
54                 int top = 0;
55                         
56                 foreach (string s in tester){
57                         if (s != list [top]){
58                                 Console.WriteLine ("Failure, got {0} expected {1}", s, list [top]);
59                                 return 1;
60                         }
61                         top++;
62                 }
63                 if (top != list.Length){
64                         Console.WriteLine ("Failure, expected {0} got {1}", list.Length, top);
65                 }
66                 Console.WriteLine ("Success");
67                 return 0;
68         }
69 }