diff options
author | Miguel de Icaza <miguel@gnome.org> | 2002-03-08 01:59:52 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2002-03-08 01:59:52 +0300 |
commit | c64db63e31d11f37912ce33a1fa10cc2f33d2611 (patch) | |
tree | c3bb5ed80ea004b5c7205a98cbdd3eb70be30146 /mcs/tests/test-52.cs | |
parent | 5ce65b8c3ad0e64385ec1a598ac0c48923ff5179 (diff) |
Removed stale comments from Object.cs
Lots of bug fixes today, including a major bugfix/upgrade to `foreach'.
2002-03-07 Miguel de Icaza <miguel@ximian.com>
* statement.cs (Foreach): Lots of work to accomodate a particular
kind of foreach statement that I had not kept in mind. It is
possible to have foreachs on classes that provide a GetEnumerator
method that return objects that implement the "pattern" for using
a foreach, there is no need to support GetEnumerator
specifically.
This is needed to compile nant.
* decl.cs: Only report 114 if the member is not `Finalize' and if
the warning level is at least 2.
* class.cs: Moved the compare function from Method to
MethodSignature.
(MethodSignature.InheritableMemberSignatureCompare): Add new
filter function that is used to extract inheritable methods from a
class.
(Method.Define): Use the new `inheritable_method_signature_filter'
delegate
* cs-tokenizer.cs (get_cmd_arg): Do not add white space to the
command.
svn path=/trunk/mcs/; revision=2981
Diffstat (limited to 'mcs/tests/test-52.cs')
-rwxr-xr-x | mcs/tests/test-52.cs | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/mcs/tests/test-52.cs b/mcs/tests/test-52.cs index 47bf0afc3e5..f16e6264696 100755 --- a/mcs/tests/test-52.cs +++ b/mcs/tests/test-52.cs @@ -1,17 +1,79 @@ +// +// Tests the foreach on strings, and tests the implicit use of foreach +// to pull the enumerator from the class and identify the pattern to be called +// using System; +using System.Collections; + +class Y { + int count = 0; + + public bool MoveNext () + { + count++; + return count != 10; + } + + public object Current { + get { + return count; + } + } +} class X { static string [] a = { "one", "two", "three" }; + + public Y GetEnumerator () + { + return new Y (); + } static int Main () { + // + // String test + // + string total = ""; + foreach (string s in a){ - Console.WriteLine (s); + total = total + s; + } + if (total != "onetwothree") + return 1; + + // + // Pattern test + // + X x = new X (); + + int t = 0; + foreach (object o in x){ + t += (int) o; } + if (t != 45) + return 2; + + // + // Looking for GetEnumerator on interfaces test + // + Hashtable xx = new Hashtable (); + xx.Add ("A", 10); + xx.Add ("B", 20); + + IDictionary vars = xx; + string total2 = ""; + foreach (string name in vars.Keys){ + total2 = total2 + name; + } + + if (total2 != "AB") + return 3; + Console.WriteLine ("test passes"); return 0; } } |