test262/website/resources/scripts/testcases2/11.12_Conditional_Operator....

99 lines
8.8 KiB
JSON

{
"testCollection": {
"name": "11.12_Conditional_Operator",
"numTests": 15,
"tests": [
{
"section": "11.12",
"description": "Checking by using eval",
"test": "//CHECK#1\nif ((eval(\"false\\u0009?\\u0009true\\u0009:\\u0009true\")) !== true) {\n $ERROR('#1: (false\\\\u0009?\\\\u0009true\\\\u0009:\\\\u0009true) === true');\n}\n\n//CHECK#2\nif ((eval(\"false\\u000B?\\u000Btrue\\u000B:\\u000Btrue\")) !== true) {\n $ERROR('#2: (false\\\\u000B?\\\\u000Btrue\\\\u000B:\\\\u000Btrue) === true');\n}\n\n//CHECK#3\nif ((eval(\"false\\u000C?\\u000Ctrue\\u000C:\\u000Ctrue\")) !== true) {\n $ERROR('#3: (false\\\\u000C?\\\\u000Ctrue\\\\u000C:\\\\u000Ctrue) === true');\n}\n\n//CHECK#4\nif ((eval(\"false\\u0020?\\u0020true\\u0020:\\u0020true\")) !== true) {\n $ERROR('#4: (false\\\\u0020?\\\\u0020true\\\\u0020:\\\\u0020true) === true');\n}\n\n//CHECK#5\nif ((eval(\"false\\u00A0?\\u00A0true\\u00A0:\\u00A0true\")) !== true) {\n $ERROR('#5: (false\\\\u00A0?\\\\u00A0true\\\\u00A0:\\\\u00A0true) === true');\n}\n\n//CHECK#6\nif ((eval(\"false\\u000A?\\u000Atrue\\u000A:\\u000Atrue\")) !== true) {\n $ERROR('#6: (false\\\\u000A?\\\\u000Atrue\\\\u000A:\\\\u000Atrue) === true');\n}\n\n//CHECK#7\nif ((eval(\"false\\u000D?\\u000Dtrue\\u000D:\\u000Dtrue\")) !== true) {\n $ERROR('#7: (false\\\\u000D?\\\\u000Dtrue\\\\u000D:\\\\u000Dtrue) === true');\n}\n\n//CHECK#8\nif ((eval(\"false\\u2028?\\u2028true\\u2028:\\u2028true\")) !== true) {\n $ERROR('#8: (false\\\\u2028?\\\\u2028true\\\\u2028:\\\\u2028true) === true');\n}\n\n//CHECK#9\nif ((eval(\"false\\u2029?\\u2029true\\u2029:\\u2029true\")) !== true) {\n $ERROR('#9: (false\\\\u2029?\\\\u2029true\\\\u2029:\\\\u2029true) === true');\n}\n\n//CHECK#10\nif ((eval(\"false\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029?\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029true\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029:\\u0009\\u000B\\u000C\\u0020\\u00A0\\u000A\\u000D\\u2028\\u2029true\")) !== true) {\n $ERROR('#10: (false\\\\u0009\\\\u000B\\\\u000C\\\\u0020\\\\u00A0\\\\u000A\\\\u000D\\\\u2028\\\\u2029?\\\\u0009\\\\u000B\\\\u000C\\\\u0020\\\\u00A0\\\\u000A\\\\u000D\\\\u2028\\\\u2029true\\\\u0009\\\\u000B\\\\u000C\\\\u0020\\\\u00A0\\\\u000A\\\\u000D\\\\u2028\\\\u2029:\\\\u0009\\\\u000B\\\\u000C\\\\u0020\\\\u00A0\\\\u000A\\\\u000D\\\\u2028\\\\u2029true) === true');\n}\n",
"id": "S11.12_A1"
},
{
"section": "11.12, 8.7.1",
"description": "Either Type is not Reference or GetBase is not null",
"test": "//CHECK#1\nif ((true ? false : true) !== false) {\n $ERROR('#1: (true ? false : true) === false');\n}\n\n//CHECK#2\nif ((false ? false : true) !== true) {\n $ERROR('#2: (false ? false : true) === true');\n}\n\n//CHECK#3\nvar x = new Boolean(true);\nvar y = new Boolean(false);\nif ((x ? y : true) !== y) {\n $ERROR('#3: var x = new Boolean(true); var y = new Boolean(false); (x ? y : true) === y');\n}\n\n//CHECK#4\nvar z = new Boolean(true);\nif ((false ? false : z) !== z) {\n $ERROR('#4: var z = new Boolean(true); (false ? false : z) === z');\n}\n\n//CHECK#5\nvar x = new Boolean(true);\nvar y = new Boolean(false);\nvar z = new Boolean(true);\nif ((x ? y : z) !== y) {\n $ERROR('#5: var x = new Boolean(true); var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === y');\n}\n\n//CHECK#6\nvar x = false;\nvar y = new Boolean(false);\nvar z = new Boolean(true);\nif ((x ? y : z) !== z) {\n $ERROR('#6: var x = false; var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === z');\n}\n",
"id": "S11.12_A2.1_T1"
},
{
"section": "11.12, 8.7.1",
"description": "If GetBase(x) is null, throw ReferenceError",
"test": "//CHECK#1\ntry {\n x ? true : false;\n $ERROR('#1.1: x ? true : false throw ReferenceError. Actual: ' + (x ? true : false)); \n}\ncatch (e) {\n if ((e instanceof ReferenceError) !== true) {\n $ERROR('#1.2: x ? true : false throw ReferenceError. Actual: ' + (e)); \n }\n}\n",
"id": "S11.12_A2.1_T2"
},
{
"section": "11.12, 8.7.1",
"description": "If ToBoolean(x) is true and GetBase(y) is null, throw ReferenceError",
"test": "//CHECK#1\ntry {\n true ? y : false;\n $ERROR('#1.1: true ? y : false throw ReferenceError. Actual: ' + (true ? y : false)); \n}\ncatch (e) {\n if ((e instanceof ReferenceError) !== true) {\n $ERROR('#1.2: true ? y : false throw ReferenceError. Actual: ' + (e)); \n }\n}\n",
"id": "S11.12_A2.1_T3"
},
{
"section": "11.12, 8.7.1",
"description": "If ToBoolean(x) is false and GetBase(z) is null, throw ReferenceError",
"test": "//CHECK#1\ntry {\n false ? true : z;\n $ERROR('#1.1: false ? true : z throw ReferenceError. Actual: ' + (false ? true : z)); \n}\ncatch (e) {\n if ((e instanceof ReferenceError) !== true) {\n $ERROR('#1.2: false ? true : z throw ReferenceError. Actual: ' + (e)); \n }\n}\n",
"id": "S11.12_A2.1_T4"
},
{
"section": "11.12, 8.7.1, 16",
"description": "If ToBoolean(x) is true and GetBase(z) is null, return y",
"test": "//CHECK#1\nvar y = new Object();\nif ((true ? y : z) !== y) {\n $ERROR('#1: var y = new Object(); (true ? y : z) === y');\n}\n",
"id": "S11.12_A2.1_T5"
},
{
"section": "11.12, 8.7.1, 16",
"description": "If ToBoolean(x) is false and GetBase(y) is null, return z",
"test": "//CHECK#1\nvar z = new Object();\nif ((false ? y : z) !== z) {\n $ERROR('#1: var z = new Object(); (false ? y : z) === z');\n}\n",
"id": "S11.12_A2.1_T6"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are boolean primitives",
"test": "//CHECK#1\nif ((false ? false : true) !== true) {\n $ERROR('#1: (false ? false : true) === true');\n}\n\n//CHECK#2\nvar z = new Boolean(true);\nif ((false ? true : z) !== z) {\n $ERROR('#2: (var y = new Boolean(true); (false ? true : z) === z');\n}\n",
"id": "S11.12_A3_T1"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are number primitives",
"test": "//CHECK#1\nif ((0 ? 0 : 1) !== 1) {\n $ERROR('#1: (0 ? 0 : 1) === 1');\n}\n\n//CHECK#2\nvar z = new Number(1);\nif ((0 ? 1 : z) !== z) {\n $ERROR('#2: (var y = new Number(1); (0 ? 1 : z) === z');\n}\n",
"id": "S11.12_A3_T2"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are string primitives",
"test": "//CHECK#1\nif ((\"\" ? \"\" : \"1\") !== \"1\") {\n $ERROR('#1: (\"\" ? \"\" : \"1\") === \"1\"');\n}\n\n//CHECK#2\nvar z = new String(\"1\");\nif ((\"\" ? \"1\" : z) !== z) {\n $ERROR('#2: (var y = new String(\"1\"); (\"\" ? \"1\" : z) === z');\n}\n",
"id": "S11.12_A3_T3"
},
{
"section": "11.12",
"description": "Type(x) or Type(y) is changed between null and undefined",
"test": "//CHECK#1\nif ((false ? true : undefined) !== undefined) {\n $ERROR('#1: (false ? true : undefined) === undefined');\n}\n\n//CHECK#2\nif ((false ? true : null) !== null) {\n $ERROR('#2: (false ? true : null) === null');\n}\n",
"id": "S11.12_A3_T4"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are boolean primitives",
"test": "//CHECK#1\nif ((true ? false : true) !== false) {\n $ERROR('#1: (true ? false : true) === false');\n}\n\n//CHECK#2\nvar y = new Boolean(true);\nif ((true ? y : false) !== y) {\n $ERROR('#2: (var y = new Boolean(true); (true ? y : false) === y');\n}\n\n//CHECK#3\nvar y = new Boolean(false);\nif ((y ? y : true) !== y) {\n $ERROR('#3: (var y = new Boolean(false); (y ? y : true) === y');\n}\n",
"id": "S11.12_A4_T1"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are number primitives",
"test": "//CHECK#1\nif ((1 ? 0 : 1) !== 0) {\n $ERROR('#1: (1 ? 0 : 1) === 0');\n}\n\n//CHECK#2\nvar y = new Number(1);\nif ((1 ? y : 0) !== y) {\n $ERROR('#2: (var y = new Number(1); (1 ? y : 0) === y');\n}\n\n//CHECK#3\nvar y = new Number(NaN);\nif ((y ? y : 1) !== y) {\n $ERROR('#3: (var y = new Number(NaN); (y ? y : 1) === y');\n}\n",
"id": "S11.12_A4_T2"
},
{
"section": "11.12",
"description": "Type(y) and Type(z) are string primitives",
"test": "//CHECK#1\nif ((\"1\" ? \"\" : \"1\") !== \"\") {\n $ERROR('#1: (\"1\" ? \"\" : \"1\") === \"\"');\n}\n\n//CHECK#2\nvar y = new String(\"1\");\nif ((\"1\" ? y : \"\") !== y) {\n $ERROR('#2: (var y = new String(\"1\"); (\"1\" ? y : \"\") === y');\n}\n\n//CHECK#3\nvar y = new String(\"y\");\nif ((y ? y : \"1\") !== y) {\n $ERROR('#3: (var y = new String(\"y\"); (y ? y : \"1\") === y');\n}\n",
"id": "S11.12_A4_T3"
},
{
"section": "11.12",
"description": "Type(x) or Type(y) is changed between null and undefined",
"test": "//CHECK#1\nif ((true ? undefined : true) !== undefined) {\n $ERROR('#1: (true ? undefined : true) === undefined');\n}\n\n//CHECK#2\nif ((true ? null : true) !== null) {\n $ERROR('#2: (true ? null : true) === null');\n}\n",
"id": "S11.12_A4_T4"
}
]
}
}