Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gtest-358.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 631dfb89c55ab89e312a5e0fb2e8d69395adb35a (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
// Tests broken equality and inequality operators

using System;

struct Foo
{
	public static bool operator == (Foo d1, Foo d2)
	{
		throw new ApplicationException ();
	}
		
	public static bool operator != (Foo d1, Foo d2)
	{
		throw new ApplicationException ();	
	}
}

struct S2
{
	public static bool operator == (S2 d1, S2? d2)
	{
		throw new ApplicationException ();
	}
		
	public static bool operator != (S2 d1, S2? d2)
	{
		throw new ApplicationException ();	
	}
}

public struct S3
{
	public static decimal operator != (S3 a, object b)
	{
		return -1;
	}
	
	public static decimal operator == (S3 a, object b)
	{
		return 1;
	}
}


public class Test
{
	static Foo ctx;
	static S2? s2;
	static S3? s3;

	public static int Main ()
	{
		if (ctx == null)
			return 1;
		
		bool b = ctx != null;
		if (!b)
			return 2;
		
		if (s2 != null)
			return 3;
		
		s3 = new S3 ();
		decimal d = s3.Value == null;
		if (d != 1)
			return 4;
		
		Console.WriteLine ("ok");
		return 0;
	}
}