Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / gtest-538.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4
5 public struct S : IEnumerable<int>
6 {
7         public S (int i)
8         {
9         }
10
11         public IEnumerator<int> GetEnumerator ()
12         {
13                 return new Enumerator<int> ();
14         }
15
16         IEnumerator IEnumerable.GetEnumerator ()
17         {
18                 throw new ApplicationException ();
19         }
20 }
21
22 public struct S2
23 {
24         public IEnumerator<int> GetEnumerator ()
25         {
26                 return new Enumerator<int> ();
27         }
28 }
29
30 public struct Enumerator<T> : IEnumerator<T>
31 {
32         public T Current {
33                 get {
34                         throw new NotImplementedException ();
35                 }
36         }
37
38         object IEnumerator.Current {
39                 get {
40                         throw new NotImplementedException ();
41                 }
42         }
43
44         public bool MoveNext ()
45         {
46                 return false;
47         }
48
49         public void Reset ()
50         {
51                 throw new NotImplementedException ();
52         }
53
54         public void Dispose ()
55         {
56                 MySystem.DisposeCounter++;
57         }
58 }
59
60 public class MySystem
61 {
62         public static int DisposeCounter;
63
64         public static int Main ()
65         {
66                 S? s = new S ();
67                 foreach (var a in s) {
68                 }
69
70                 if (DisposeCounter != 1)
71                         return 1;
72
73                 S2? s2 = new S2 ();
74                 foreach (var a in s2) {
75                 }
76
77                 if (DisposeCounter != 2)
78                         return 2;
79
80                 return 0;
81         }
82 }