1 // Compiler options: -langversion:latest
5 // parser conditional and cast expression tests
10 public static int Value
;
13 public class ConditionalParsing
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
)
29 const int c
= true ? 1 : 2;
36 struct MyTestStruct
: IDisposable
38 public void Dispose ()
42 public static implicit operator MyTestStruct (int i
)
44 return new MyTestStruct ();
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 ("");
79 char[] escaped_text_chars
=
81 new char [] {'&', '<', '>', '\r', '\n'}
:
82 new char [] {'&', '<', '>'}
;
85 void Test_7 (object o
)
90 void Test_8 (DateTime
value)
92 var _endDate
= value > DateTime
.MinValue
? new DateTime
? (value) : null;
99 string a
= (b
? (c
? "#" : "#") : "");
104 int i
= new int [] { 1, 2, 3 }
[1];
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
)
122 void Test_13 (object param
)
124 if (param
as bool? ?? false) {} else {}
129 bool a
= false, b
= false;
132 return a
? (b
? c
as int? : null) : null;
135 Action
<int> Test_15 (Action
<int> arg
)
137 return arg
?? (Helper
<int>);
142 bool? b
= Test (1, arg
:2);
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;
166 var t
= (Object
)string.Empty
;
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
)
193 public static void Main ()