[ilasm] Don't break arguments compatiblity
[mono-project.git] / mcs / tests / gtest-409.cs
blobd8fee033830cf1a65ea14b44a462ef8c0dc6eb77
1 using System;
3 //
4 // parser conditional and cast expression tests
5 //
7 class A<T>
9 public static int Value;
12 public class ConditionalParsing
14 class T
16 public T (string path, bool mode)
17 : this (path, mode, (mode == true ? 1 : 2), 1, int.MaxValue)
21 public T (string s, bool m, int i, int i2, int i3)
26 class Const
28 const int c = true ? 1 : 2;
31 struct S
35 struct MyTestStruct : IDisposable
37 public void Dispose ()
41 public static implicit operator MyTestStruct (int i)
43 return new MyTestStruct ();
47 void Test_1 (bool a)
49 int? b = a ? 3 : 4;
52 void Test_2 ()
54 string mp = "";
55 int a = 1;
56 int _provider = mp.Length == a ? _provider = 4 : 5;
59 T? Test_3<T> (Func<T, T, T> result, T t) where T : struct
61 return new T? (result (t, t));
64 void Test_4 (bool x, bool y)
66 int s = x ? (y ? 2 : 4) : (y ? 5 : 7);
69 void Test_5 (bool a, IDisposable fs)
71 using (a ? fs : null) {
72 Console.WriteLine ("");
76 void Test_6 (bool a)
78 char[] escaped_text_chars =
79 a != false ?
80 new char [] {'&', '<', '>', '\r', '\n'} :
81 new char [] {'&', '<', '>'};
84 void Test_7 (object o)
86 object a = (S?[]) o;
89 void Test_8 (DateTime value)
91 var _endDate = value > DateTime.MinValue ? new DateTime ? (value) : null;
94 void Test_9 ()
96 bool b = (1 == 2);
97 bool c = (1 == 1);
98 string a = (b ? (c ? "#" : "#") : "");
101 void Test_10 ()
103 int i = new int [] { 1, 2, 3 } [1];
106 void Test_11 ()
108 int a = (int)(A<int>.Value);
111 static int Test_12 (bool arg)
113 return arg ? Foo (() => { return 1; }) : 1;
116 static int Foo (Func<int> arg)
118 return 1;
121 void Test_13 (object param)
123 if (param as bool? ?? false) {} else {}
126 int? Test_14 ()
128 bool a = false, b = false;
129 object c = null;
131 return a ? (b ? c as int? : null) : null;
134 Action<int> Test_15 (Action<int> arg)
136 return arg ?? (Helper<int>);
139 void Test_16 ()
141 bool? b = Test (1, arg:2);
144 void Test_17 ()
147 using (MyTestStruct? mts = (int?) 1)
153 void Test_18 (bool b, Action a)
155 var e = b ? () => { } : a;
158 void Test_19 (int[,] table)
160 var x = 1 > 0 ? table[5, 1] : 0;
163 void Test_20 ()
165 var t = (Object)string.Empty;
168 void Test_21 ()
170 var t = (Int32)sbyte.MaxValue;
173 static void Helper<T> (T arg)
177 static bool Test (object b, int arg)
179 return false;
182 public static void Main ()