cleol
[mcs.git] / tests / gtest-117.cs
blob1e07e91cf03d975e9db2706b6dcdef8d0b00dd39
1 // Compiler options: -warnaserror
3 using System;
5 public interface IFoo<T>
6 { }
8 public class Foo<T>
10 public static bool Test (T x)
12 return x is IFoo<T>;
15 public static bool Test ()
17 T t = default (T);
18 return t is int;
21 public static bool TestB ()
23 T t = default (T);
24 return t is int?;
28 class Y<T> where T : struct
30 public bool Foo ()
32 object o = null;
33 return o is System.Nullable <T>;
37 class X
39 public static bool TestA (object o)
41 return o is int?;
44 public static bool TestB<T> (T o)
46 return o is int[];
49 public static int TestC ()
51 int? i = null;
52 if (i is int) {
53 return (int) i;
56 return 3;
59 static int Main ()
61 if (Foo<int>.Test (3))
62 return 1;
64 if (!Foo<int>.Test())
65 return 2;
67 // False expected int? != null
68 if (Foo<int?>.TestB())
69 return 3;
71 int? i = 0;
72 if (!TestA(i))
73 return 4;
75 int[] a = new int[0];
76 if (!TestB(a))
77 return 5;
79 if (TestC () != 3)
80 return 6;
82 Console.WriteLine ("OK");
83 return 0;