20 references to TestConditional
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (20)
Semantics\ConditionalOperatorTests.cs (20)
26TestConditional("true ? 1 : 2", expectedType: "System.Int32");
27TestConditional("false ? 'a' : 'b'", expectedType: "System.Char");
28TestConditional("true ? 1.5 : GetDouble()", expectedType: "System.Double");
29TestConditional("false ? GetObject() : GetObject()", expectedType: "System.Object");
30TestConditional("true ? GetUserGeneric<T>() : GetUserGeneric<T>()", expectedType: "D<T>");
31TestConditional("false ? GetTypeParameter<T>() : GetTypeParameter<T>()", expectedType: "T");
40TestConditional("true ? GetShort() : GetInt()", expectedType: "System.Int32");
41TestConditional("false ? \"string\" : GetObject()", expectedType: "System.Object");
42TestConditional("true ? GetVariantInterface<string, int>() : GetVariantInterface<object, int>()", expectedType: "I<System.String, System.Int32>");
43TestConditional("false ? GetVariantInterface<int, object>() : GetVariantInterface<int, string>()", expectedType: "I<System.Int32, System.Object>");
59TestConditional("true ? 1 : (short)2", expectedType: "System.Int32");
60TestConditional("false ? (float)2 : 1", expectedType: "System.Single");
61TestConditional("true ? 1.5d : (double)2", expectedType: "System.Double");
91TestConditional("true ? GetObject() : null", expectedType: "System.Object"); //null literal
92TestConditional("false ? GetString : (System.Func<string>)null", expectedType: "System.Func<System.String>"); //method group
93TestConditional("true ? (System.Func<int, int>)null : x => x", expectedType: "System.Func<System.Int32, System.Int32>"); //lambda
142TestConditional("GetBool() ? 1 : 2", "System.Int32");
157TestConditional("true? 0 : color.Blue", "color");
167TestConditional(@"(1 < 2) ? ""MyString"" as string : "" """, "System.String");
168TestConditional(@"(1 > 2) ? "" "" : ""MyString"" as string", "System.String");