Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / tests / test-119.cs
1 class Value {
2         public static explicit operator int (Value val)
3         {
4                 return 1;
5         }
6
7         public static explicit operator MyObject (Value val)
8         {
9                 return new MyObject (1);
10         }       
11
12         public static explicit operator uint (Value val)
13         {
14                 return 1;
15         }
16 }
17
18 class MyObject {
19         public MyObject (int i) {}
20 }
21
22 class Derived : MyObject {
23         public Derived (int i) : base (i) { }
24
25         Derived Blah ()
26         {
27                 Value val = new Value ();
28
29                 return (Derived) val;
30         }
31 }
32
33 class Test {
34         public static int Main ()
35         {
36                 Value v = new Value ();
37
38                 v = null;
39
40                 try {
41                         // This will throw an exception.
42                         // This test is more of a compile test, we need a real
43                         // good test that does not require this lame catch.
44                         Derived d = (Derived) v;
45                 } catch {
46                 }
47
48                 return 0;
49         }
50 }