[bcl] Update BCL Linked Size
[mono-project.git] / mcs / tests / gtest-409.cs
blob606ae3685d1462432300edfd7cf4ea8ddd15dff8
1 // Compiler options: -langversion:latest
2 using System;
4 //
5 // parser conditional and cast expression tests
6 //
8 class A<T>
10 public static int Value;
13 public class ConditionalParsing
15 class T
17 public T (string path, bool mode)
18 : this (path, mode, (mode == true ? 1 : 2), 1, int.MaxValue)
22 public T (string s, bool m, int i, int i2, int i3)
27 class Const
29 const int c = true ? 1 : 2;
32 struct S
36 struct MyTestStruct : IDisposable
38 public void Dispose ()
42 public static implicit operator MyTestStruct (int i)
44 return new MyTestStruct ();
48 void Test_1 (bool a)
50 int? b = a ? 3 : 4;
53 void Test_2 ()
55 string mp = "";
56 int a = 1;
57 int _provider = mp.Length == a ? _provider = 4 : 5;
60 T? Test_3<T> (Func<T, T, T> result, T t) where T : struct
62 return new T? (result (t, t));
65 void Test_4 (bool x, bool y)
67 int s = x ? (y ? 2 : 4) : (y ? 5 : 7);
70 void Test_5 (bool a, IDisposable fs)
72 using (a ? fs : null) {
73 Console.WriteLine ("");
77 void Test_6 (bool a)
79 char[] escaped_text_chars =
80 a != false ?
81 new char [] {'&', '<', '>', '\r', '\n'} :
82 new char [] {'&', '<', '>'};
85 void Test_7 (object o)
87 object a = (S?[]) o;
90 void Test_8 (DateTime value)
92 var _endDate = value > DateTime.MinValue ? new DateTime ? (value) : null;
95 void Test_9 ()
97 bool b = (1 == 2);
98 bool c = (1 == 1);
99 string a = (b ? (c ? "#" : "#") : "");
102 void Test_10 ()
104 int i = new int [] { 1, 2, 3 } [1];
107 void Test_11 ()
109 int a = (int)(A<int>.Value);
112 static int Test_12 (bool arg)
114 return arg ? Foo (() => { return 1; }) : 1;
117 static int Foo (Func<int> arg)
119 return 1;
122 void Test_13 (object param)
124 if (param as bool? ?? false) {} else {}
127 int? Test_14 ()
129 bool a = false, b = false;
130 object c = null;
132 return a ? (b ? c as int? : null) : null;
135 Action<int> Test_15 (Action<int> arg)
137 return arg ?? (Helper<int>);
140 void Test_16 ()
142 bool? b = Test (1, arg:2);
145 void Test_17 ()
148 using (MyTestStruct? mts = (int?) 1)
154 void Test_18 (bool b, Action a)
156 var e = b ? () => { } : a;
159 void Test_19 (int[,] table)
161 var x = 1 > 0 ? table[5, 1] : 0;
164 void Test_20 ()
166 var t = (Object)string.Empty;
169 void Test_21 ()
171 var t = (Int32)sbyte.MaxValue;
174 void Test_22 (bool args)
176 var x = args ?.2f : -.2f;
179 void Test_23 (string args)
181 var x = args == null ? default : 1;
184 static void Helper<T> (T arg)
188 static bool Test (object b, int arg)
190 return false;
193 public static void Main ()