2010-07-09 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / tests / test-786.cs
1 using System;
2
3 public class A
4 {
5         public static int Counter;
6         public static implicit operator string (A c)
7         {
8                 ++Counter;
9                 return "A-class";
10         }
11                 
12         public static implicit operator Delegate (A c)
13         {
14                 return null;
15         }
16 }
17         
18 public struct B
19 {
20         public static int Counter;
21         public static implicit operator string (B c)
22         {
23                 ++Counter;
24                 return "B-struct";
25         }
26 }
27
28 public struct D
29 {
30         public static int Counter;
31         public static implicit operator Delegate (D d)
32         {
33                 ++Counter;
34                 return null;
35         }
36 }
37
38 public struct E
39 {
40         public static int Counter;
41         public static implicit operator bool (E d)
42         {
43                 ++Counter;
44                 return true;
45         }
46 }
47
48 class Program
49 {       
50         public static int Main ()
51         {
52                 if (new B () != new B () || B.Counter != 2)
53                         return 1;
54                 
55                 if (new B () != "B-struct" || B.Counter != 3)
56                         return 2;
57                 
58                 if (new B () == null || B.Counter != 4) {
59                         // FIXME: Incorrect null lifting
60                         //return 3;
61                 }
62
63                 if (new D () != new D () || D.Counter != 2)
64                         return 10;
65
66                 if (new D () != null || D.Counter != 3) {
67                         // FIXME: Incorrect null lifting
68                         //return 11;
69                 }
70                 
71                 if (new A () != "A-class" || A.Counter != 1)
72                         return 20;
73                 
74                 if (new A () == null  || A.Counter != 1)
75                         return 21;
76
77                 if (new E () != new E ()  || E.Counter != 2)
78                         return 31;
79                 
80                 Console.WriteLine ("ok");
81                 return 0;
82         }
83 }