[Mono.Unix] Fix crasher in StringToHeap (#5639)
[mono.git] / mcs / tests / gtest-etree-04.cs
1 using System;
2 using System.Linq.Expressions;
3
4 struct Foo
5 {
6         public static bool operator > (Foo d1, Foo d2)
7         {
8                 throw new ApplicationException ();
9         }
10         
11         public static bool operator < (Foo d1, Foo d2)
12         {
13                 throw new ApplicationException ();
14         }
15         
16         public static bool operator == (Foo d1, Foo d2)
17         {
18                 throw new ApplicationException ();
19         }
20                 
21         public static bool operator != (Foo d1, Foo d2)
22         {
23                 throw new ApplicationException ();
24         }
25         
26         public static Foo operator + (Foo d1, Foo d2)
27         {
28                 throw new ApplicationException ();
29         }
30 }
31
32 class C
33 {
34         public static int Main()
35         {
36                 Foo f;
37                 Expression<Func<bool>> e = () => f > null;
38                 if (e.Compile ().Invoke ())
39                         return 1;
40                 
41                 e = () => f < null;
42                 if (e.Compile ().Invoke ())
43                         return 2;
44                 
45                 e = () => f == null;
46                 if (e.Compile ().Invoke ())
47                         return 3;
48                 
49                 e = () => f != null;
50                 if (!e.Compile ().Invoke ())
51                         return 4;
52                 
53                 Expression<Func<Foo?>> e2 = () => f + null;
54                 if (e2.Compile ().Invoke () != null)
55                         return 5;
56
57                 Console.WriteLine ("OK");
58                 return 0;
59         }
60 }