[CI] ignore appdomain-unload-asmload.exe on interp and full-aot
[mono.git] / mono / tests / bug-400716.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4
5 namespace Repro {
6         public enum Bla {
7                 A,B
8         }
9
10         class Driver {
11
12                 static void TestEnumerator<K, T> ()
13                 {
14                         object obj = new K[10];
15                         IEnumerable<T> dd = (IEnumerable<T>)obj;
16                         var tx = dd.GetEnumerator ();
17                         IEnumerator<T> x = (IEnumerator<T>)tx;
18                         x.MoveNext ();
19                         T t = x.Current;
20                 }
21
22                 static void TestBadEnumerator<K, T> ()
23                 {
24                         try {
25                                 object obj = new K[10];
26                                 IEnumerable<T> dd = (IEnumerable<T>)obj;
27                                 var tx = dd.GetEnumerator ();
28                                 IEnumerator<T> x = (IEnumerator<T>)tx;
29                                 x.MoveNext ();
30                                 T t = x.Current;
31                                 throw new Exception (string.Format ("An InvalidCastException should be thrown for {0} and {1}", typeof (K), typeof (T)));
32                         } catch (InvalidCastException) {
33
34                         }
35                 }
36
37                 public static int Main ()
38                 {
39                         TestEnumerator<byte, byte> ();
40                         TestEnumerator<byte, sbyte> ();
41                         TestEnumerator<sbyte, byte> ();
42                         TestEnumerator<sbyte, sbyte> ();
43
44                         TestEnumerator<int, int> ();
45                         TestEnumerator<int, uint> ();
46                         TestEnumerator<uint, int> ();
47                         TestEnumerator<uint, uint> ();
48
49                         TestEnumerator<Bla, Bla> ();
50                         TestEnumerator<Bla, int> ();
51
52                         TestEnumerator<byte[], byte[]> ();
53                         TestEnumerator<byte[], sbyte[]> ();
54                         TestEnumerator<byte[], ICollection<byte>> ();
55                         TestEnumerator<byte[], IEnumerable<byte>> ();
56                         TestEnumerator<byte[], IList<byte>> ();
57                         TestEnumerator<byte[], ICollection<sbyte>> ();
58                         TestEnumerator<byte[], IEnumerable<sbyte>> ();
59                         TestEnumerator<byte[], IList<sbyte>> ();
60                         TestEnumerator<byte[], object> ();
61                         TestEnumerator<byte[], Array> ();
62
63                         TestBadEnumerator<byte[], object[]> ();
64                         TestBadEnumerator<byte[], byte> ();
65                         TestBadEnumerator<byte[], sbyte> ();
66                         TestBadEnumerator<byte[], ICollection<object>> ();
67
68                         TestEnumerator<char[], char[]> ();
69                         TestEnumerator<char[], IEnumerable<char>> ();
70
71                         TestEnumerator<int[], IEnumerable<int>> ();
72                         TestEnumerator<int[], IEnumerable<uint>> ();
73
74                         return 0;
75                 }
76         }
77 }
78