[mono/tests] Fix out of tree build.
[mono-project.git] / mcs / tests / test-282.cs
blobd08521ac9bde3213fa655b4dc479377286c30d19
1 // Bug #62322.
2 using System;
4 public struct integer
6 private readonly int value;
8 public integer (int value)
10 this.value = value;
13 public static implicit operator integer (int i)
15 return new integer (i);
18 public static implicit operator double (integer i)
20 return Convert.ToDouble (i.value);
23 public static integer operator + (integer x, integer y)
25 return new integer (x.value + y.value);
29 class X
31 public static object Add (integer x, object other)
33 if (other is int) return x + ((int) other);
34 if (other is double) return x + ((double) other);
35 throw new InvalidOperationException ();
38 public static int Main ()
40 integer i = new integer (3);
41 double d = 4.0;
43 object result = Add (i, d);
44 if (!(result is double))
45 return 1;
47 if ((double) result != 7.0)
48 return 2;
50 return 0;