diff options
Diffstat (limited to 'external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator')
15 files changed, 373 insertions, 0 deletions
diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A1.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A1.js new file mode 100644 index 000000000..2e4d3f23a --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A1.js @@ -0,0 +1,59 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A1; +* @section: 11.12; +* @assertion: White Space and Line Terminator between LogicalORExpression and "?" or between "?" and AssignmentExpression or between AssignmentExpression and ":" or between ":" and AssignmentExpression are allowed; +* @description: Checking by using eval; +*/ + +//CHECK#1 +if ((eval("false\u0009?\u0009true\u0009:\u0009true")) !== true) { + $ERROR('#1: (false\\u0009?\\u0009true\\u0009:\\u0009true) === true'); +} + +//CHECK#2 +if ((eval("false\u000B?\u000Btrue\u000B:\u000Btrue")) !== true) { + $ERROR('#2: (false\\u000B?\\u000Btrue\\u000B:\\u000Btrue) === true'); +} + +//CHECK#3 +if ((eval("false\u000C?\u000Ctrue\u000C:\u000Ctrue")) !== true) { + $ERROR('#3: (false\\u000C?\\u000Ctrue\\u000C:\\u000Ctrue) === true'); +} + +//CHECK#4 +if ((eval("false\u0020?\u0020true\u0020:\u0020true")) !== true) { + $ERROR('#4: (false\\u0020?\\u0020true\\u0020:\\u0020true) === true'); +} + +//CHECK#5 +if ((eval("false\u00A0?\u00A0true\u00A0:\u00A0true")) !== true) { + $ERROR('#5: (false\\u00A0?\\u00A0true\\u00A0:\\u00A0true) === true'); +} + +//CHECK#6 +if ((eval("false\u000A?\u000Atrue\u000A:\u000Atrue")) !== true) { + $ERROR('#6: (false\\u000A?\\u000Atrue\\u000A:\\u000Atrue) === true'); +} + +//CHECK#7 +if ((eval("false\u000D?\u000Dtrue\u000D:\u000Dtrue")) !== true) { + $ERROR('#7: (false\\u000D?\\u000Dtrue\\u000D:\\u000Dtrue) === true'); +} + +//CHECK#8 +if ((eval("false\u2028?\u2028true\u2028:\u2028true")) !== true) { + $ERROR('#8: (false\\u2028?\\u2028true\\u2028:\\u2028true) === true'); +} + +//CHECK#9 +if ((eval("false\u2029?\u2029true\u2029:\u2029true")) !== true) { + $ERROR('#9: (false\\u2029?\\u2029true\\u2029:\\u2029true) === true'); +} + +//CHECK#10 +if ((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) { + $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'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T1.js new file mode 100644 index 000000000..9dd3fb29b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T1.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T1; +* @section: 11.12, 8.7.1; +* @assertion: Operator x ? y : z uses GetValue; +* @description: Either Type is not Reference or GetBase is not null; +*/ + +//CHECK#1 +if ((true ? false : true) !== false) { + $ERROR('#1: (true ? false : true) === false'); +} + +//CHECK#2 +if ((false ? false : true) !== true) { + $ERROR('#2: (false ? false : true) === true'); +} + +//CHECK#3 +var x = new Boolean(true); +var y = new Boolean(false); +if ((x ? y : true) !== y) { + $ERROR('#3: var x = new Boolean(true); var y = new Boolean(false); (x ? y : true) === y'); +} + +//CHECK#4 +var z = new Boolean(true); +if ((false ? false : z) !== z) { + $ERROR('#4: var z = new Boolean(true); (false ? false : z) === z'); +} + +//CHECK#5 +var x = new Boolean(true); +var y = new Boolean(false); +var z = new Boolean(true); +if ((x ? y : z) !== y) { + $ERROR('#5: var x = new Boolean(true); var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === y'); +} + +//CHECK#6 +var x = false; +var y = new Boolean(false); +var z = new Boolean(true); +if ((x ? y : z) !== z) { + $ERROR('#6: var x = false; var y = new Boolean(false); var z = new Boolean(true); (x ? y : z) === z'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T2.js new file mode 100644 index 000000000..c800904f8 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T2; +* @section: 11.12, 8.7.1; +* @assertion: Operator x ? y : z uses GetValue; +* @description: If GetBase(x) is null, throw ReferenceError; +*/ + +//CHECK#1 +try { + x ? true : false; + $ERROR('#1.1: x ? true : false throw ReferenceError. Actual: ' + (x ? true : false)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + $ERROR('#1.2: x ? true : false throw ReferenceError. Actual: ' + (e)); + } +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T3.js new file mode 100644 index 000000000..16d2e310b --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T3; +* @section: 11.12, 8.7.1; +* @assertion: Operator x ? y : z uses GetValue; +* @description: If ToBoolean(x) is true and GetBase(y) is null, throw ReferenceError; +*/ + +//CHECK#1 +try { + true ? y : false; + $ERROR('#1.1: true ? y : false throw ReferenceError. Actual: ' + (true ? y : false)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + $ERROR('#1.2: true ? y : false throw ReferenceError. Actual: ' + (e)); + } +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T4.js new file mode 100644 index 000000000..44b969330 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T4; +* @section: 11.12, 8.7.1; +* @assertion: Operator x ? y : z uses GetValue; +* @description: If ToBoolean(x) is false and GetBase(z) is null, throw ReferenceError; +*/ + +//CHECK#1 +try { + false ? true : z; + $ERROR('#1.1: false ? true : z throw ReferenceError. Actual: ' + (false ? true : z)); +} +catch (e) { + if ((e instanceof ReferenceError) !== true) { + $ERROR('#1.2: false ? true : z throw ReferenceError. Actual: ' + (e)); + } +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T5.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T5.js new file mode 100644 index 000000000..17263398d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T5.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T5; +* @section: 11.12, 8.7.1, 16; +* @assertion: Operator x ? y : z uses GetValue; +* @description: If ToBoolean(x) is true and GetBase(z) is null, return y; +*/ + +//CHECK#1 +var y = new Object(); +if ((true ? y : z) !== y) { + $ERROR('#1: var y = new Object(); (true ? y : z) === y'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T6.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T6.js new file mode 100644 index 000000000..d4c4ff2b9 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A2.1_T6.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A2.1_T6; +* @section: 11.12, 8.7.1, 16; +* @assertion: Operator x ? y : z uses GetValue; +* @description: If ToBoolean(x) is false and GetBase(y) is null, return z; +*/ + +//CHECK#1 +var z = new Object(); +if ((false ? y : z) !== z) { + $ERROR('#1: var z = new Object(); (false ? y : z) === z'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T1.js new file mode 100644 index 000000000..b3b02fa68 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A3_T1; +* @section: 11.12; +* @assertion: If ToBoolean(x) is false, return z; +* @description: Type(y) and Type(z) are boolean primitives; +*/ + +//CHECK#1 +if ((false ? false : true) !== true) { + $ERROR('#1: (false ? false : true) === true'); +} + +//CHECK#2 +var z = new Boolean(true); +if ((false ? true : z) !== z) { + $ERROR('#2: (var y = new Boolean(true); (false ? true : z) === z'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T2.js new file mode 100644 index 000000000..3bfc4b563 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** + * @name: S11.12_A3_T2; + * @section: 11.12; + * @assertion: If ToBoolean(x) is false, return z; + * @description: Type(y) and Type(z) are number primitives; + */ + +//CHECK#1 +if ((0 ? 0 : 1) !== 1) { + $ERROR('#1: (0 ? 0 : 1) === 1'); +} + +//CHECK#2 +var z = new Number(1); +if ((0 ? 1 : z) !== z) { + $ERROR('#2: (var y = new Number(1); (0 ? 1 : z) === z'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T3.js new file mode 100644 index 000000000..45b2c5d0d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A3_T3; +* @section: 11.12; +* @assertion: If ToBoolean(x) is false, return z; +* @description: Type(y) and Type(z) are string primitives; +*/ + +//CHECK#1 +if (("" ? "" : "1") !== "1") { + $ERROR('#1: ("" ? "" : "1") === "1"'); +} + +//CHECK#2 +var z = new String("1"); +if (("" ? "1" : z) !== z) { + $ERROR('#2: (var y = new String("1"); ("" ? "1" : z) === z'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T4.js new file mode 100644 index 000000000..747795e0d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A3_T4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A3_T4; +* @section: 11.12; +* @assertion: If ToBoolean(x) is false, return z; +* @description: Type(x) or Type(y) is changed between null and undefined; +*/ + +//CHECK#1 +if ((false ? true : undefined) !== undefined) { + $ERROR('#1: (false ? true : undefined) === undefined'); +} + +//CHECK#2 +if ((false ? true : null) !== null) { + $ERROR('#2: (false ? true : null) === null'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T1.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T1.js new file mode 100644 index 000000000..7c53a3ef6 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T1.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A4_T1; +* @section: 11.12; +* @assertion: If ToBoolean(x) is true, return y; +* @description: Type(y) and Type(z) are boolean primitives; +*/ + +//CHECK#1 +if ((true ? false : true) !== false) { + $ERROR('#1: (true ? false : true) === false'); +} + +//CHECK#2 +var y = new Boolean(true); +if ((true ? y : false) !== y) { + $ERROR('#2: (var y = new Boolean(true); (true ? y : false) === y'); +} + +//CHECK#3 +var y = new Boolean(false); +if ((y ? y : true) !== y) { + $ERROR('#3: (var y = new Boolean(false); (y ? y : true) === y'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T2.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T2.js new file mode 100644 index 000000000..6c4624cfb --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T2.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A4_T2; +* @section: 11.12; +* @assertion: If ToBoolean(x) is true, return y; +* @description: Type(y) and Type(z) are number primitives; +*/ + +//CHECK#1 +if ((1 ? 0 : 1) !== 0) { + $ERROR('#1: (1 ? 0 : 1) === 0'); +} + +//CHECK#2 +var y = new Number(1); +if ((1 ? y : 0) !== y) { + $ERROR('#2: (var y = new Number(1); (1 ? y : 0) === y'); +} + +//CHECK#3 +var y = new Number(NaN); +if ((y ? y : 1) !== y) { + $ERROR('#3: (var y = new Number(NaN); (y ? y : 1) === y'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T3.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T3.js new file mode 100644 index 000000000..450afd290 --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T3.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A4_T3; +* @section: 11.12; +* @assertion: If ToBoolean(x) is true, return y; +* @description: Type(y) and Type(z) are string primitives; +*/ + +//CHECK#1 +if (("1" ? "" : "1") !== "") { + $ERROR('#1: ("1" ? "" : "1") === ""'); +} + +//CHECK#2 +var y = new String("1"); +if (("1" ? y : "") !== y) { + $ERROR('#2: (var y = new String("1"); ("1" ? y : "") === y'); +} + +//CHECK#3 +var y = new String("y"); +if ((y ? y : "1") !== y) { + $ERROR('#3: (var y = new String("y"); (y ? y : "1") === y'); +} diff --git a/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T4.js b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T4.js new file mode 100644 index 000000000..011126a5d --- /dev/null +++ b/external/contributions/Google/sputniktests/tests/Conformance/11_Expressions/11.12_Conditional_Operator/S11.12_A4_T4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/** +* @name: S11.12_A4_T4; +* @section: 11.12; +* @assertion: If ToBoolean(x) is true, return y; +* @description: Type(x) or Type(y) is changed between null and undefined; +*/ + +//CHECK#1 +if ((true ? undefined : true) !== undefined) { + $ERROR('#1: (true ? undefined : true) === undefined'); +} + +//CHECK#2 +if ((true ? null : true) !== null) { + $ERROR('#2: (true ? null : true) === null'); +} |