Move Enum and CorElementType to shared (dotnet/coreclr#23177)
[mono-project.git] / mcs / tests / test-229.cs
blob79bf893a000eb53bf61d76cbdf597c151994aa33
1 using System;
2 using System.Collections;
3 using System.Collections.Specialized;
5 public class List : IEnumerable {
7 int pos = 0;
8 int [] items;
10 public List (int i)
12 items = new int [i];
15 public void Add (int value)
17 items [pos ++] = value;
20 public MyEnumerator GetEnumerator ()
22 return new MyEnumerator(this);
25 IEnumerator IEnumerable.GetEnumerator ()
27 return GetEnumerator ();
30 public struct MyEnumerator : IEnumerator {
32 List l;
33 int p;
35 public MyEnumerator (List l)
37 this.l = l;
38 p = -1;
41 public object Current {
42 get {
43 return l.items [p];
47 public bool MoveNext()
49 return ++p < l.pos;
52 public void Reset()
54 p = 0;
59 public class UberList : List {
60 public UberList (int i) : base (i)
64 public static int Main(string[] args)
66 return One () && Two () && Three () ? 0 : 1;
70 static bool One ()
72 List l = new List (1);
73 l.Add (1);
75 foreach (int i in l)
76 if (i == 1)
77 return true;
78 return false;
81 static bool Two ()
83 List l = new UberList (1);
84 l.Add (1);
86 foreach (int i in l)
87 if (i == 1)
88 return true;
89 return false;
92 static bool Three ()
94 UberList l = new UberList (1);
95 l.Add (1);
97 foreach (int i in l)
98 if (i == 1)
99 return true;
100 return false;