summaryrefslogtreecommitdiff
path: root/mcs/tests/gtest-586.cs
blob: 6d018082cb5e107e2076298aa0dcabc539e1c5f4 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;

struct S
{
	public static bool operator == (S s, S i)
	{
		throw new ApplicationException ();
	}

	public static bool operator != (S s, S i)
	{
		throw new ApplicationException ();
	}
}

struct S2
{
	public static int counter;

	public static bool operator == (S2 s, S2 i)
	{
		counter++;
		return true;
	}

	public static bool operator != (S2 s, S2 i)
	{
		throw new ApplicationException ();
	}
}


struct S3
{
	public static int counter;

	public static implicit operator int?(S3 arg)
	{
		counter++;
		return null;
	}
}

class C
{
	public static int Main ()
	{
		S? s = new S ();
		S? s2 = null;
		S? s4 = null;

		if ((s == s2) != false)
			return 1;

		if ((s2 == s) != false)
			return 2;

		if ((s2 == s4) != true)
			return 3;

		S x = new S ();

		if ((s2 == x) != false)
			return 5;

		if ((x == s2) != false)
			return 6;

		S2? s2_1 = new S2 ();
		S2? s2_3 = new S2 ();
		S2 x2 = new S2 ();

		if ((s2_1 == s2_3) != true)
			return 7;

		if ((s2_1 == x2) != true)
			return 8;

		if ((x2 == s2_1) != true)
			return 9;

		if (S2.counter != 3)
			return 10;

		S3 s3;

		if ((s3 == null) != true)
			return 20;

		if ((null == s3) != true)
			return 21;

		if (S3.counter != 2)
			return 22;

		return 0;
	}
}