223 lines
14 KiB
Text
223 lines
14 KiB
Text
=== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts ===
|
|
//Cond ? Expr1 : Expr2, Cond is of boolean type, Expr1 and Expr2 have the same type
|
|
var condBoolean: boolean;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
|
|
var exprAny1: any;
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
|
|
var exprBoolean1: boolean;
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
var exprNumber1: number;
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
|
|
var exprString1: string;
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
|
|
var exprIsObject1: Object;
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
|
|
|
var exprAny2: any;
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
var exprBoolean2: boolean;
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
var exprNumber2: number;
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
var exprString2: string;
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
var exprIsObject2: Object;
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
|
|
|
//Cond is a boolean type variable
|
|
condBoolean ? exprAny1 : exprAny2;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
condBoolean ? exprBoolean1 : exprBoolean2;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
condBoolean ? exprNumber1 : exprNumber2;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
condBoolean ? exprString1 : exprString2;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
condBoolean ? exprIsObject1 : exprIsObject2;
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
condBoolean ? exprString1 : exprBoolean1; // union
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
//Cond is a boolean type literal
|
|
true ? exprAny1 : exprAny2;
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
false ? exprBoolean1 : exprBoolean2;
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
true ? exprNumber1 : exprNumber2;
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
false ? exprString1 : exprString2;
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
true ? exprIsObject1 : exprIsObject2;
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
true ? exprString1 : exprBoolean1; // union
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
//Cond is a boolean type expression
|
|
!true ? exprAny1 : exprAny2;
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
2 > 1 ? exprNumber1 : exprNumber2;
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
null === undefined ? exprString1 : exprString2;
|
|
>undefined : Symbol(undefined)
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
true || false ? exprIsObject1 : exprIsObject2;
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
null === undefined ? exprString1 : exprBoolean1; // union
|
|
>undefined : Symbol(undefined)
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
//Results shoud be same as Expr1 and Expr2
|
|
var resultIsAny1 = condBoolean ? exprAny1 : exprAny2;
|
|
>resultIsAny1 : Symbol(resultIsAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 40, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
var resultIsBoolean1 = condBoolean ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean1 : Symbol(resultIsBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 41, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
var resultIsNumber1 = condBoolean ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber1 : Symbol(resultIsNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 42, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
var resultIsString1 = condBoolean ? exprString1 : exprString2;
|
|
>resultIsString1 : Symbol(resultIsString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 43, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject1 : Symbol(resultIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 44, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean1 : Symbol(resultIsStringOrBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 45, 3))
|
|
>condBoolean : Symbol(condBoolean, Decl(conditionalOperatorConditionIsBooleanType.ts, 1, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
var resultIsAny2 = true ? exprAny1 : exprAny2;
|
|
>resultIsAny2 : Symbol(resultIsAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 47, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean2 : Symbol(resultIsBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 48, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
var resultIsNumber2 = true ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber2 : Symbol(resultIsNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 49, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
var resultIsString2 = false ? exprString1 : exprString2;
|
|
>resultIsString2 : Symbol(resultIsString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 50, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
var resultIsObject2 = true ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject2 : Symbol(resultIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 51, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean2 : Symbol(resultIsStringOrBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 52, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean3 : Symbol(resultIsStringOrBoolean3, Decl(conditionalOperatorConditionIsBooleanType.ts, 53, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|
|
var resultIsAny3 = !true ? exprAny1 : exprAny2;
|
|
>resultIsAny3 : Symbol(resultIsAny3, Decl(conditionalOperatorConditionIsBooleanType.ts, 55, 3))
|
|
>exprAny1 : Symbol(exprAny1, Decl(conditionalOperatorConditionIsBooleanType.ts, 3, 3))
|
|
>exprAny2 : Symbol(exprAny2, Decl(conditionalOperatorConditionIsBooleanType.ts, 9, 3))
|
|
|
|
var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
|
|
>resultIsBoolean3 : Symbol(resultIsBoolean3, Decl(conditionalOperatorConditionIsBooleanType.ts, 56, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
>exprBoolean2 : Symbol(exprBoolean2, Decl(conditionalOperatorConditionIsBooleanType.ts, 10, 3))
|
|
|
|
var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2;
|
|
>resultIsNumber3 : Symbol(resultIsNumber3, Decl(conditionalOperatorConditionIsBooleanType.ts, 57, 3))
|
|
>exprNumber1 : Symbol(exprNumber1, Decl(conditionalOperatorConditionIsBooleanType.ts, 5, 3))
|
|
>exprNumber2 : Symbol(exprNumber2, Decl(conditionalOperatorConditionIsBooleanType.ts, 11, 3))
|
|
|
|
var resultIsString3 = null === undefined ? exprString1 : exprString2;
|
|
>resultIsString3 : Symbol(resultIsString3, Decl(conditionalOperatorConditionIsBooleanType.ts, 58, 3))
|
|
>undefined : Symbol(undefined)
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprString2 : Symbol(exprString2, Decl(conditionalOperatorConditionIsBooleanType.ts, 12, 3))
|
|
|
|
var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2;
|
|
>resultIsObject3 : Symbol(resultIsObject3, Decl(conditionalOperatorConditionIsBooleanType.ts, 59, 3))
|
|
>exprIsObject1 : Symbol(exprIsObject1, Decl(conditionalOperatorConditionIsBooleanType.ts, 7, 3))
|
|
>exprIsObject2 : Symbol(exprIsObject2, Decl(conditionalOperatorConditionIsBooleanType.ts, 13, 3))
|
|
|
|
var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union
|
|
>resultIsStringOrBoolean4 : Symbol(resultIsStringOrBoolean4, Decl(conditionalOperatorConditionIsBooleanType.ts, 60, 3))
|
|
>exprString1 : Symbol(exprString1, Decl(conditionalOperatorConditionIsBooleanType.ts, 6, 3))
|
|
>exprBoolean1 : Symbol(exprBoolean1, Decl(conditionalOperatorConditionIsBooleanType.ts, 4, 3))
|
|
|