summaryrefslogtreecommitdiff
path: root/mcs/tests/test-882.cs
blob: 67200e068d29951eb695bd683ce63b1bb9c95d78 (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
66
67
68
69
70
71
72
using System;

public class MyUInt32
{
	public uint x;

	public MyUInt32 (uint x)
	{
		this.x = x;
	}

	public static implicit operator uint (MyUInt32 v)
	{
		return v.x;
	}

	public static implicit operator long (MyUInt32 v)
	{
		throw new ApplicationException ();
	}

	public static implicit operator MyUInt32 (uint v)
	{
		return new MyUInt32 (v);
	}

	public static implicit operator MyUInt32 (long v)
	{
		throw new ApplicationException ();
	}
}

class Test
{
	static MyUInt32 test1 (MyUInt32 x)
	{
		x = x + 1;
		return x;
	}

	static MyUInt32 test2 (MyUInt32 x)
	{
		x++;
		return x;
	}

	static MyUInt32 test3 (MyUInt32 x)
	{
		++x;
		return x;
	}

	public static int Main ()
	{
		var m = new MyUInt32 (2);
		m = test1 (m);
		if (m.x != 3)
			return 1;

		m = new MyUInt32 (2);
		m = test2 (m);
		if (m.x != 3)
			return 2;

		m = new MyUInt32 (3);
		m = test3 (m);
		if (m.x != 4)
			return 3;

		return 0;
	}
}