diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/fromCharCode')
17 files changed, 572 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.js new file mode 100644 index 0000000000..64b994fe33 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the fromCharCode function is 1 +es5id: 15.5.3.2_A1 +description: Checking String.fromCharCode.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof String.fromCharCode !== "function") { + $ERROR('#1: typeof String.fromCharCode === "function". Actual: typeof String.fromCharCode ===' + typeof String.fromCharCode); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(String.hasOwnProperty("fromCharCode"))) { + $ERROR('#2: String.hasOwnProperty("fromCharCode") return true. Actual: ' + String.hasOwnProperty("fromCharCode")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (String.fromCharCode.length !== 1) { + $ERROR('#3: String.fromCharCode.length === 1. Actual: String.fromCharCode.length ===' + String.fromCharCode.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js new file mode 100644 index 0000000000..e824a9c611 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode () returns empty string +es5id: 15.5.3.2_A2 +description: Call String.fromCharCode() +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.fromCharCode() !== "") { + $ERROR('#1: String.fromCharCode () returns empty string. Actual: ' + String.fromCharCode()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js new file mode 100644 index 0000000000..f4c39415f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] ) +es5id: 15.5.3.2_A3_T1 +description: Call String.fromCharCode(65,66,66,65) +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.fromCharCode(65, 66, 66, 65) !== "ABBA") { + $ERROR('#1: String.fromCharCode(65,66,66,65) === "ABBA". Actual: String.fromCharCode(65,66,66,65) ===' + String.fromCharCode(65, 66, 66, 65)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js new file mode 100644 index 0000000000..5dd9ddd406 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] ) +es5id: 15.5.3.2_A3_T2 +description: > + Create function variable, that equal String.fromCharCode, delete + original String.fromCharCode and use created variable +---*/ + +var __fcc__func = String.fromCharCode; + +delete String.fromCharCode; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__fcc__func(65, 66, 66, 65) !== "ABBA") { + $ERROR('#1: __fcc__func = String.fromCharCode; delete String.fromCharCode; __fcc__func(65,66,66,65) === "ABBA". Actual: __fcc__func(65,66,66,65) ===' + __fcc__func(65, 66, 66, 65)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js new file mode 100644 index 0000000000..7bcb1bc40b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode has not [[construct]] method +es5id: 15.5.3.2_A4 +description: Checking if creating "new String.fromCharCode" fails +---*/ + +var __fcc__func = String.fromCharCode; + +delete String.fromCharCode; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __obj = new __fcc__func(65, 66, 66, 65); + $ERROR('#1: __fcc__func = String.fromCharCode; var __obj = new __fcc__func(65,66,66,65) lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js new file mode 100644 index 0000000000..66abbeaa93 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If value is NaN, +0, -0, +Infinity, or -Infinity, return +0 +es5id: 9.7_A1 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(Number.NaN).charCodeAt(0) !== +0) { + $ERROR('#1.1: String.fromCharCode(Number.NaN).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.NaN).charCodeAt(0))); +} else if (1 / String.fromCharCode(Number.NaN).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR('#1.2: String.fromCharCode(Number.NaN).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#2 +if (String.fromCharCode(Number("abc")).charCodeAt(0) !== +0) { + $ERROR('#2.1: String.fromCharCode(Number("abc")).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number("abc")).charCodeAt(0))); +} else if (1 / String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR('#2.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#3 +if (String.fromCharCode(0).charCodeAt(0) !== +0) { + $ERROR('#3.1: String.fromCharCode(0).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(0).charCodeAt(0))); +} else if (1 / String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR('#3.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#4 +if (String.fromCharCode(-0).charCodeAt(0) !== +0) { + $ERROR("#4.1: String.fromCharCode(-0).charCodeAt(0) === +0"); +} else if (1 / String.fromCharCode(-0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR("#4.2: String.fromCharCode(-0).charCodeAt(0) === +0. Actual: -0"); +} + +// CHECK#5 +if (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== +0) { + $ERROR('#5.1: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0))); +} else if (1 / String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR('#5.2: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#6 +if (String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== +0) { + $ERROR("#6.1: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0"); +} else if (1 / String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + $ERROR("#6.2: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0. Actual: -0"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js new file mode 100644 index 0000000000..41e106018c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: ToUint16 returns values between 0 and 2^16-1 +es5id: 9.7_A2.1 +description: > + Converting numbers, which are in\outside of Uint16 scopes, with + String.fromCharCode(Number).charCodeAt(0) construction +---*/ + +// CHECK#1 +if (String.fromCharCode(0).charCodeAt(0) !== 0) { + $ERROR('#1: String.fromCharCode(0).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(0).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(1).charCodeAt(0) !== 1) { + $ERROR('#2: String.fromCharCode(1).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(1).charCodeAt(0))); +} + +// CHECK#3 +if (String.fromCharCode(-1).charCodeAt(0) !== 65535) { + $ERROR('#3: String.fromCharCode(-1).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-1).charCodeAt(0))); +} + +// CHECK#4 +if (String.fromCharCode(65535).charCodeAt(0) !== 65535) { + $ERROR('#4: String.fromCharCode(65535).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(65535).charCodeAt(0))); +} + +// CHECK#5 +if (String.fromCharCode(65534).charCodeAt(0) !== 65534) { + $ERROR('#5: String.fromCharCode(65534).charCodeAt(0) === 65534. Actual: ' + (String.fromCharCode(65534).charCodeAt(0))); +} + +// CHECK#6 +if (String.fromCharCode(65536).charCodeAt(0) !== 0) { + $ERROR('#6: String.fromCharCode(65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(65536).charCodeAt(0))); +} + +// CHECK#7 +if (String.fromCharCode(4294967295).charCodeAt(0) !== 65535) { + $ERROR('#7: String.fromCharCode(4294967295).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(4294967295).charCodeAt(0))); +} + +// CHECK#8 +if (String.fromCharCode(4294967294).charCodeAt(0) !== 65534) { + $ERROR('#8: String.fromCharCode(4294967294).charCodeAt(0) === 65534. Actual: ' + (String.fromCharCode(4294967294).charCodeAt(0))); +} + +// CHECK#9 +if (String.fromCharCode(4294967296).charCodeAt(0) !== 0) { + $ERROR('#9: String.fromCharCode(4294967296).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(4294967296).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js new file mode 100644 index 0000000000..48531c546d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Compute result modulo 2^16 +es5id: 9.7_A2.2 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(-32767).charCodeAt(0) !== 32769) { + $ERROR('#1: String.fromCharCode(-32767).charCodeAt(0) === 32769. Actual: ' + (String.fromCharCode(-32767).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-32768).charCodeAt(0) !== 32768) { + $ERROR('#2: String.fromCharCode(-32768).charCodeAt(0) === 32768. Actual: ' + (String.fromCharCode(-32768).charCodeAt(0))); +} + +// CHECK#3 +if (String.fromCharCode(-32769).charCodeAt(0) !== 32767) { + $ERROR('#3: String.fromCharCode(-32769).charCodeAt(0) === 32767. Actual: ' + (String.fromCharCode(-32769).charCodeAt(0))); +} + +// CHECK#4 +if (String.fromCharCode(-65535).charCodeAt(0) !== 1) { + $ERROR('#4: String.fromCharCode(-65535).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(-65535).charCodeAt(0))); +} + +// CHECK#5 +if (String.fromCharCode(-65536).charCodeAt(0) !== 0) { + $ERROR('#5: String.fromCharCode(-65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(-65536).charCodeAt(0))); +} + +// CHECK#6 +if (String.fromCharCode(-65537).charCodeAt(0) !== 65535) { + $ERROR('#6: String.fromCharCode(-65537).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-65537).charCodeAt(0))); +} + +// CHECK#7 +if (String.fromCharCode(65535).charCodeAt(0) !== 65535) { + $ERROR('#7: String.fromCharCode(65535).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(65535).charCodeAt(0))); +} + +// CHECK#8 +if (String.fromCharCode(65536).charCodeAt(0) !== 0) { + $ERROR('#8: String.fromCharCode(65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(65536).charCodeAt(0))); +} + +// CHECK#9 +if (String.fromCharCode(65537).charCodeAt(0) !== 1) { + $ERROR('#9: String.fromCharCode(65537).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(65537).charCodeAt(0))); +} + +// CHECK#10 +if (String.fromCharCode(131071).charCodeAt(0) !== 65535) { + $ERROR('#10: String.fromCharCode(131071).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(131071).charCodeAt(0))); +} + +// CHECK#11 +if (String.fromCharCode(131072).charCodeAt(0) !== 0) { + $ERROR('#11: String.fromCharCode(131072).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(131072).charCodeAt(0))); +} + +// CHECK#12 +if (String.fromCharCode(131073).charCodeAt(0) !== 1) { + $ERROR('#12: String.fromCharCode(131073).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(131073).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T1.js new file mode 100644 index 0000000000..6f9446b496 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_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. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T1 +description: Type(x) is Boolean +---*/ + +// CHECK#1 +if (String.fromCharCode(new Boolean(true)).charCodeAt(0) !== 1) { + $ERROR('#1: String.fromCharCode(new Boolean(true)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new Boolean(true)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(false).charCodeAt(0) !== 0) { + $ERROR('#2: String.fromCharCode(false).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(false).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T2.js new file mode 100644 index 0000000000..1a6aa99eb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.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. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T2 +description: Type(x) is Number +---*/ + +// CHECK#1 +if (String.fromCharCode(new Number(1)).charCodeAt(0) !== 1) { + $ERROR('#1: String.fromCharCode(new Number(1)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new Number(1)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-1.234).charCodeAt(0) !== 65535) { + $ERROR('#2: String.fromCharCode(-1.234).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-1.234).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T3.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T3.js new file mode 100644 index 0000000000..53976f50b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.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. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T3 +description: Type(x) is String +---*/ + +// CHECK#1 +if (String.fromCharCode(new String(1)).charCodeAt(0) !== 1) { + $ERROR('#1: String.fromCharCode(new String(1)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new String(1)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode("-1.234").charCodeAt(0) !== 65535) { + $ERROR('#2: String.fromCharCode("-1.234").charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode("-1.234").charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js new file mode 100644 index 0000000000..bf9dfe4421 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js @@ -0,0 +1,129 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T4 +description: Type(x) is Object +---*/ + +//CHECK#1 +var object = { + valueOf: function() { + return 1 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#1: var object = {valueOf: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#2 +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#2: var object = {valueOf: function() {return 1}, toString: function() {return 0}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#3 +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#3: var object = {valueOf: function() {return 1}, toString: function() {return {}}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#4.1: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); + } +} +catch (e) { + if (e === "error") { + $ERROR('#4.2: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; object not throw "error"'); + } else { + $ERROR('#4.3: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; object not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return 1 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#5: var object = {toString: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + $ERROR('#6: var object = {valueOf: function() {return {}}, toString: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + object >>> 0; + $ERROR('#7.1: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object throw "error". Actual: ' + (object >>> 0)); +} +catch (e) { + if (e !== "error") { + $ERROR('#7.2: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + object >>> 0; + $ERROR('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object throw TypeError. Actual: ' + (object >>> 0)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js new file mode 100644 index 0000000000..bd5358043c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses floor, abs +es5id: 9.7_A3.2_T1 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(1.2345).charCodeAt(0) !== 1) { + $ERROR('#1: String.fromCharCode(1.2345).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(1.2345).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-5.4321).charCodeAt(0) !== 65531) { + $ERROR('#2: String.fromCharCode(-5.4321).charCodeAt(0) === 65531. Actual: ' + (String.fromCharCode(-5.4321).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/browser.js b/js/src/tests/test262/built-ins/String/fromCharCode/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/browser.js diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/name.js b/js/src/tests/test262/built-ins/String/fromCharCode/name.js new file mode 100644 index 0000000000..aad7ed2c18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.1.2.1 +description: > + String.fromCharCode.name is "fromCharCode". +info: | + String.fromCharCode ( ...codeUnits ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.fromCharCode.name, "fromCharCode"); + +verifyNotEnumerable(String.fromCharCode, "name"); +verifyNotWritable(String.fromCharCode, "name"); +verifyConfigurable(String.fromCharCode, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js new file mode 100644 index 0000000000..2076c9b6ab --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + String.fromCharCode does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(String.fromCharCode), false, 'isConstructor(String.fromCharCode) must return false'); + +assert.throws(TypeError, () => { + new String.fromCharCode(); +}, '`new String.fromCharCode()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/shell.js b/js/src/tests/test262/built-ins/String/fromCharCode/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/shell.js |