Merge pull request #1322 from StephenMcConnel/bug23532
[mono.git] / mcs / tests / test-pattern-06.cs
1 // Compiler options: -langversion:experimental
2
3 using System;
4
5 class RecursiveNamedPattern
6 {
7         public static int Main ()
8         {
9                 if (Switch_1 (null) != 4)
10                         return 1;
11
12                 if (Switch_1 ("x") != 5)
13                         return 2;
14
15                 if (Switch_1 (1) != 1)
16                         return 3;
17
18 //              if (Switch_1 (new C1 ()) != 3)
19 //                      return 4;
20
21                 if (Switch_1 ((byte?) 1) != 1)
22                         return 5;
23
24                 if (Switch_2 (new C1 ()) != 3)
25                         return 10;
26
27                 if (Switch_2 (null) != 2)
28                         return 11;
29
30                 Console.WriteLine ("ok");
31                 return 0;
32         }
33
34         static int Switch_1 (object o)
35         {
36                 switch (o) {
37                         case 1:
38                                 return 1;
39 //                      case C1 (3):
40 //                              return 2;
41 //                      case C1 (2):
42 //                              return 3;
43                         case null:
44                                 return 4;
45                         default:
46                                 return 5;
47                 }
48         }
49
50         static int Switch_2 (C1 o)
51         {
52                 switch (o) {
53                         case null:
54                                 return 2;
55                 }
56
57                 return 3;
58         }
59 }
60
61 public class C1
62 {
63         public static bool operator is (C1 c1, out int i)
64         {
65                 i = 2;
66                 return true;
67         }
68 }