2009-02-15 Jonathan Chambers <joncham@gmail.com>
[mcs.git] / tests / test-282.cs
blobf455d86580b8305ab96e1691cb56fb7d2f6a1620
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 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;