New test.
authorMartin Baulig <martin@novell.com>
Fri, 8 Jul 2005 16:43:41 +0000 (16:43 -0000)
committerMartin Baulig <martin@novell.com>
Fri, 8 Jul 2005 16:43:41 +0000 (16:43 -0000)
svn path=/trunk/mcs/; revision=47111

mcs/tests/test-iter-10.cs [new file with mode: 0644]

diff --git a/mcs/tests/test-iter-10.cs b/mcs/tests/test-iter-10.cs
new file mode 100644 (file)
index 0000000..b2ad3c8
--- /dev/null
@@ -0,0 +1,53 @@
+using System;
+using System.Collections;
+
+class X {
+       static IEnumerator GetIt
+       {
+           get {
+               yield return 1;
+               yield return 2;
+               yield return 3;
+           }
+           set
+           {
+           }       
+       }
+       
+       IEnumerable this [int i]
+       {
+           get {
+               yield return 1*i;
+               yield return 2*i;
+               yield return 3*i;
+           }
+           set
+           {
+           }
+       }
+
+       static int Main ()
+       {
+               IEnumerator e = GetIt;
+               int total = 0;
+               
+               while (e.MoveNext ()){
+                       Console.WriteLine ("Value=" + e.Current);
+                       total += (int) e.Current;
+               }
+
+               if (total != 6)
+                       return 1;
+
+               total = 0;
+               X x = new X ();
+               foreach (int i in x [2]){
+                       Console.WriteLine ("Value=" + i);
+                       total += i;
+               }
+               if (total != 12)
+                       return 2;
+               
+               return 0;
+       }
+}