[runtime] Coverage profiler fixes (#5698)
[mono.git] / mcs / tests / gtest-variance-11.cs
1 using System;
2
3 interface IContravariant<in T>
4 {
5 }
6
7 interface ICovariant<out T>
8 {
9 }
10
11 class D
12 {
13         public static bool Contra<T> (IContravariant<T> e1, IContravariant<T> e2)
14         {
15                 Console.WriteLine (typeof (T));
16                 return typeof (T) == typeof (string);
17         }
18         
19         public static bool Covariant<T> (ICovariant<T> e1, ICovariant<T> e2)
20         {
21                 Console.WriteLine (typeof (T));
22                 return typeof (T) == typeof (object);
23         }
24         
25         public static bool CovContCont<T> (ICovariant<T> e1, IContravariant<T> e2, IContravariant<T> e3)
26         {
27                 Console.WriteLine (typeof (T));
28                 return typeof (T) == typeof (string);
29         }
30
31         public static bool ContCovContCov<T> (IContravariant<T> e1, ICovariant<T> e2, IContravariant<T> e3, ICovariant<T> e4)
32         {
33                 Console.WriteLine (typeof (T));
34                 return typeof (T) == typeof (string);
35         }
36         
37         public static bool CovCovCont<T> (ICovariant<T> e1, ICovariant<T> e2, IContravariant<T> e3)
38         {
39                 Console.WriteLine (typeof (T));
40                 return typeof (T) == typeof (string);
41         }
42         
43         public static int Main ()
44         {
45                 
46                 ICovariant<object> a = null;
47                 ICovariant<string> b = null;
48                 if (!Covariant (a, b))
49                         return 1;
50                 
51                 IContravariant<string> a_1 = null;
52                 IContravariant<object> b_1 = null;
53                 if (!Contra (a_1, b_1))
54                         return 2;
55                 
56                 ICovariant<string> a_2 = null;
57                 IContravariant<object> b_2 = null;
58                 IContravariant<string> c_2 = null;
59                 if (!CovContCont (a_2, b_2, c_2))
60                         return 3;
61                 
62                 IContravariant<object> a_3 = null;
63                 ICovariant<string> b_3 = null;
64                 IContravariant<string> c_3 = null;
65                 ICovariant<string> d_3 = null;
66                 if (!ContCovContCov (a_3, b_3, c_3, d_3))
67                         return 4;
68                 
69                 Console.WriteLine ("ok");
70                 return 0;
71         }
72 }