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

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

public struct integer
{
	private readonly int value;

	public integer (int value)
	{
		this.value = value;
	}

	public static implicit operator integer (int i)
	{
		return new integer (i);
	}

	public static implicit operator double (integer i)
	{
		return Convert.ToDouble (i.value);
	}

	public static integer operator + (integer x, integer y)
	{
		return new integer (x.value + y.value);
	}
}

class X
{
	public static object Add (integer x, object other)
	{
		if (other is int) return x + ((int) other);
		if (other is double) return x + ((double) other);
		throw new InvalidOperationException ();
	}

	public static int Main ()
	{
		integer i = new integer (3);
		double d = 4.0;

		object result = Add (i, d);
		if (!(result is double))
			return 1;

		if ((double) result != 7.0)
			return 2;

		return 0;
	}
}