Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / test-pattern-02.cs
1 // Compiler options: -langversion:experimental
2
3 using System;
4
5 enum MyEnum : short
6 {
7         V_4 = 4
8 }
9
10 class ConstantPattern
11 {
12         static bool Generic<T> (T t) where T : class
13         {
14                 return t is default (T);
15         }
16
17         public static int Main ()
18         {
19                 bool b4 = false;
20                 b4 = !b4;
21                 object o = "x";
22                 bool r1 = o is "y";
23                 if (r1)
24                         return 1;
25
26                 r1 = o is "x";
27                 if (!r1)
28                         return 2;
29
30                 string s = "o";
31                 if (s is null)
32                         return 3;
33
34                 if (s is "oo")
35                         return 4;
36
37                 if (!(s is "o"))
38                         return 5;
39
40                 int? o3 = 4;
41                 bool r3 = o3 is null;
42                 if (r3)
43                         return 6;
44                 
45                 r3 = o3 is 4;
46                 if (!r3)
47                         return 7;
48
49                 object o4 = (byte?)255;
50                 var ggg = o4 is 255;
51                 if (ggg)
52                         return 8;
53
54                 if (o4 is null)
55                         return 9;
56
57                 object o5 = (double)-255;
58                 if (o5 is -byte.MaxValue)
59                         return 10;
60
61                 object o6 = MyEnum.V_4;
62                 bool r4 = o6 is 4;
63                 if (r4)
64                         return 11;
65
66                 r4 = o6 is MyEnum.V_4;
67                 if (!r4)
68                         return 12;
69
70                 ConstantPattern o7 = new ConstantPattern ();
71                 if (!(o7 is ConstantPattern))
72                         return 13;
73
74                 if (!(o7 is object))
75                         return 14;
76
77                 object o8 = true;
78                 if (o8 is false)
79                         return 15;
80
81                 if (!(o8 is true))
82                         return 16;
83
84                 if (Generic (""))
85                         return 17;
86
87                 if (!Generic<Delegate> (null))
88                         return 18;
89
90                 Console.WriteLine ("ok");
91                 return 0;
92         }
93 }