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

test-204.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3a003a31d96f3c809af43215ce114c83862aab33 (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
using System;

class X
{
	public readonly int x;

	public X (int x)
	{
		this.x = x;
	}

	public override string ToString ()
	{
		return String.Format ("X ({0})", x);
	}

	public static X operator & (X a, X b)
	{
		return new X (a.x * b.x);
	}

	public static X operator | (X a, X b)
	{
		return new X (a.x + b.x);
	}

	// Returns true if the value is odd.
	public static bool operator true (X x)
	{
		return (x.x % 2) != 0;
	}

	// Returns true if the value is even.
	public static bool operator false (X x)
	{
		return (x.x % 2) == 0;
	}

	public static int Test ()
	{
		X x = new X (3);
		X y = new X (4);

		X t1 = x && y;
		X t2 = y && x;
		X t3 = x || y;
		X t4 = y || x;

		// Console.WriteLine ("TEST: {0} {1} {2} {3} {4} {5}", x, y, t1, t2, t3, t4);

		if (t1.x != 12)
			return 1;
		if (t2.x != 4)
			return 2;
		if (t3.x != 3)
			return 3;
		if (t4.x != 7)
			return 4;

		return 0;
	}

	public static int Main ()
	{
		int result = Test ();
		Console.WriteLine ("RESULT: {0}", result);
		return result;
	}
}