Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2009-01-03 Rodrigo Kumpera <rkumpera@novell.com>

	* bug-400716.cs: New regression test.

	* Makefile.am: Test added.

svn path=/trunk/mono/; revision=122360
  • Loading branch information...
commit dce1fcefb80a2165bdf63c2a953509fc0af5a690 1 parent 21b3a49
@kumpera kumpera authored
View
6 mono/tests/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-03 Rodrigo Kumpera <rkumpera@novell.com>
+
+ * bug-400716.cs: New regression test.
+
+ * Makefile.am: Test added.
+
2008-12-26 Rodrigo Kumpera <rkumpera@novell.com>
* bug-461261.cs: New regression test.
View
3  mono/tests/Makefile.am
@@ -331,7 +331,8 @@ BASE_TEST_CS_SRC= \
bug-389886-sre-generic-interface-instances.cs \
bug-461867.cs \
bug-461941.cs \
- bug-461261.cs
+ bug-461261.cs \
+ bug-400716.cs
if AMD64
TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs
View
78 mono/tests/bug-400716.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Repro {
+ public enum Bla {
+ A,B
+ }
+
+ class Driver {
+
+ static void TestEnumerator<K, T> ()
+ {
+ object obj = new K[10];
+ IEnumerable<T> dd = (IEnumerable<T>)obj;
+ var tx = dd.GetEnumerator ();
+ IEnumerator<T> x = (IEnumerator<T>)tx;
+ x.MoveNext ();
+ T t = x.Current;
+ }
+
+ static void TestBadEnumerator<K, T> ()
+ {
+ try {
+ object obj = new K[10];
+ IEnumerable<T> dd = (IEnumerable<T>)obj;
+ var tx = dd.GetEnumerator ();
+ IEnumerator<T> x = (IEnumerator<T>)tx;
+ x.MoveNext ();
+ T t = x.Current;
+ throw new Exception (string.Format ("An InvalidCastException should be thrown for {0} and {1}", typeof (K), typeof (T)));
+ } catch (InvalidCastException) {
+
+ }
+ }
+
+ public static int Main ()
+ {
+ TestEnumerator<byte, byte> ();
+ TestEnumerator<byte, sbyte> ();
+ TestEnumerator<sbyte, byte> ();
+ TestEnumerator<sbyte, sbyte> ();
+
+ TestEnumerator<int, int> ();
+ TestEnumerator<int, uint> ();
+ TestEnumerator<uint, int> ();
+ TestEnumerator<uint, uint> ();
+
+ TestEnumerator<Bla, Bla> ();
+ TestEnumerator<Bla, int> ();
+
+ TestEnumerator<byte[], byte[]> ();
+ TestEnumerator<byte[], sbyte[]> ();
+ TestEnumerator<byte[], ICollection<byte>> ();
+ TestEnumerator<byte[], IEnumerable<byte>> ();
+ TestEnumerator<byte[], IList<byte>> ();
+ TestEnumerator<byte[], ICollection<sbyte>> ();
+ TestEnumerator<byte[], IEnumerable<sbyte>> ();
+ TestEnumerator<byte[], IList<sbyte>> ();
+ TestEnumerator<byte[], object> ();
+ TestEnumerator<byte[], Array> ();
+
+ TestBadEnumerator<byte[], object[]> ();
+ TestBadEnumerator<byte[], byte> ();
+ TestBadEnumerator<byte[], sbyte> ();
+ TestBadEnumerator<byte[], ICollection<object>> ();
+
+ TestEnumerator<char[], char[]> ();
+ TestEnumerator<char[], IEnumerable<char>> ();
+
+ TestEnumerator<int[], IEnumerable<int>> ();
+ TestEnumerator<int[], IEnumerable<uint>> ();
+
+ return 0;
+ }
+ }
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.