2010-04-07 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / test-16.cs
blob3c59e917e191c39d521ce0560b5750e20aa461ee
1 using System;
3 namespace Mine {
5 public class Blah {
7 public static int operator + (Blah i, Blah j)
9 Console.WriteLine ("Base class binary + operator");
10 return 2;
13 public static implicit operator int (Blah i)
15 Console.WriteLine ("Blah->int");
16 return 3;
19 public static implicit operator byte (Blah i)
21 Console.WriteLine ("Blah->byte");
22 return 0;
25 public static implicit operator short (Blah i)
27 Console.WriteLine ("Blah->short");
28 return 1;
33 public class Foo : Blah {
35 public static int Main ()
37 int number = new Foo () + new Foo () ;
38 Console.WriteLine (number);
40 Foo tmp = new Foo ();
42 int k = tmp;
44 Console.WriteLine ("Convert from Foo to float");
45 float f = tmp;
46 Console.WriteLine ("Converted");
48 // The following will not work till we fix our UserCast::Emit
49 // to convert the return value on the stack.
50 if (f == 3)
51 Console.WriteLine ("Best implicit conversion selected correctly.");
53 Console.WriteLine ("F is {0}", f);
55 if (number == 2 && k == 3)
56 return 0;
57 else
58 return 1;