summaryrefslogtreecommitdiff
path: root/mcs/tests/gtest-513.cs
blob: eac3920f25536c6a6ae0c1b11a3445c583589655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;

struct S : IDisposable
{
	public static int hit;

	void IDisposable.Dispose ()
	{
		hit++;
	}

	public void Dispose ()
	{
		throw new ApplicationException ();
	}
}

class C : IDisposable
{

	void IDisposable.Dispose ()
	{
	}

	public void Dispose ()
	{
		throw new ApplicationException ();
	}
}

class Test
{
	public static int Main ()
	{
		using (new S? ()) {
		}

		if (S.hit != 0)
			return 1;

		using (new C ()) {
		}

		var s = new S ();
		using (s) {
		}

		if (S.hit != 1)
			return 2;

		GenMethod (s);

		if (S.hit != 2)
			return 3;

		Console.WriteLine ("ok");
		return 0;
	}

	static void GenMethod<T> (T t) where T : IDisposable
	{
		using (t) {
		}
	}
}