Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / gtest-513.cs
1 using System;
2
3 struct S : IDisposable
4 {
5         public static int hit;
6
7         void IDisposable.Dispose ()
8         {
9                 hit++;
10         }
11
12         public void Dispose ()
13         {
14                 throw new ApplicationException ();
15         }
16 }
17
18 class C : IDisposable
19 {
20
21         void IDisposable.Dispose ()
22         {
23         }
24
25         public void Dispose ()
26         {
27                 throw new ApplicationException ();
28         }
29 }
30
31 class Test
32 {
33         public static int Main ()
34         {
35                 using (new S? ()) {
36                 }
37
38                 if (S.hit != 0)
39                         return 1;
40
41                 using (new C ()) {
42                 }
43
44                 var s = new S ();
45                 using (s) {
46                 }
47
48                 if (S.hit != 1)
49                         return 2;
50
51                 GenMethod (s);
52
53                 if (S.hit != 2)
54                         return 3;
55
56                 Console.WriteLine ("ok");
57                 return 0;
58         }
59
60         static void GenMethod<T> (T t) where T : IDisposable
61         {
62                 using (t) {
63                 }
64         }
65 }