diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/charCodeAt')
27 files changed, 642 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.js new file mode 100644 index 0000000000..9e27b9db34 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt() can accept many arguments +es5id: 15.5.4.5_A1.1 +description: Checking by using eval +---*/ + +function __FACTORY() { + this.toString = function() { + return "wizard"; + }; +}; + +__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; + +var __instance = new __FACTORY; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charCodeAt(eval("1"), true, null, {}) !== 0x69) { + throw new Test262Error('#1: __instance.charCodeAt(eval("1"),true,null,{})=== 0x69. Actual: __instance.charCodeAt(eval("1"),true,null,{})===' + __instance.charCodeAt(eval("1"), true, null, {})); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.js new file mode 100644 index 0000000000..51d18d3db5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The String.prototype.charCodeAt.length property has the attribute ReadOnly +es5id: 15.5.4.5_A10 +description: > + Checking if varying the String.prototype.charCodeAt.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.charCodeAt.length; + +verifyNotWritable(String.prototype.charCodeAt, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.charCodeAt.length; String.prototype.charCodeAt.length = function(){return "shifted";}; String.prototype.charCodeAt.length === __obj. Actual: ' + String.prototype.charCodeAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.js new file mode 100644 index 0000000000..104b402726 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.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. + +/*--- +info: The length property of the charCodeAt method is 1 +es5id: 15.5.4.5_A11 +description: Checking String.prototype.charCodeAt.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charCodeAt.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.charCodeAt.hasOwnProperty("length") return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.length !== 1) { + throw new Test262Error('#2: String.prototype.charCodeAt.length === 1. Actual: ' + String.prototype.charCodeAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T1.js new file mode 100644 index 0000000000..53edc2e24b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_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: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T1 +description: pos is false and true, and instance is object +---*/ + +var __instance = new Object(42); + +__instance.charCodeAt = String.prototype.charCodeAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((__instance.charCodeAt(false) !== 52) || (__instance.charCodeAt(true) !== 50)) { + throw new Test262Error('#1: __instance = new Object(42); __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false) === 52 and __instance.charCodeAt(true) === 50. Actual: __instance.charCodeAt(false) ===' + __instance.charCodeAt(false) + ' and __instance.charCodeAt(true) ===' + __instance.charCodeAt(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.js new file mode 100644 index 0000000000..8548781ffe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.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.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T10 +description: Call charCodeAt() function with object argument +---*/ + +var __obj = { + toString: function() { + return 1; + } +} +var __str = "lego"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.charCodeAt(__obj) !== 0x65) { + throw new Test262Error('#1: var __obj = {toString:function(){return 1;}}; var __str = "lego"; __str.charCodeAt(__obj) === 0x65. Actual: ' + __str.charCodeAt(__obj)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js new file mode 100644 index 0000000000..f93769b079 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T2 +description: pos is equation with false and true, and instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.charCodeAt = String.prototype.charCodeAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charCodeAt(false) !== 0x66) { + throw new Test262Error('#1: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false)===0x66. Actual: ' + __instance.charCodeAt(false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.charCodeAt(true) !== 0x61) { + throw new Test262Error('#2: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true)===0x61. Actual: ' + __instance.charCodeAt(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance.charCodeAt(true + 1) !== 0x6C) { + throw new Test262Error('#3: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true+1) === 0x6C. Actual: ' + __instance.charCodeAt(true + 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T4.js new file mode 100644 index 0000000000..729817fd72 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_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. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T4 +description: Call charCodeAt() function without argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since Number() evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if ("smart".charCodeAt() !== 0x73) { + throw new Test262Error('#1: "smart".charCodeAt() === 0x73. Actual: "smart".charCodeAt() ===' + ("smart".charCodeAt())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js new file mode 100644 index 0000000000..c975a03b3a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T5 +description: Call charCodeAt() function with null argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(null) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (function() { + return "lego" + }().charCodeAt(null) !== 0x6C) { + throw new Test262Error('#1: function(){return "lego"}().charCodeAt(null) === 0x6C. Actual: ' + function() { + return "lego" + }().charCodeAt(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js new file mode 100644 index 0000000000..f45c701d11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T6 +description: > + Call charCodeAt() function with x argument of new String object, + where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (new String("lego").charCodeAt(x) !== 0x6C) { + throw new Test262Error('#1: var x; new String("lego").charCodeAt(x) === 0x6C. Actual: new String("lego").charCodeAt(x) ===' + new String("lego").charCodeAt(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.js new file mode 100644 index 0000000000..a7542ca12b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.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. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T7 +description: Call charCodeAt() function with undefined argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (String("lego").charCodeAt(undefined) !== 0x6C) { + throw new Test262Error('#1: String("lego").charCodeAt(undefined) === 0x6C. Actual: String("lego").charCodeAt(undefined) ===' + String("lego").charCodeAt(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.js new file mode 100644 index 0000000000..855cc4213f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.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. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T8 +description: Call charCodeAt() function with void 0 argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(void 0) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (String(42).charCodeAt(void 0) !== 0x34) { + throw new Test262Error('#1: String(42).charCodeAt(void 0) === 0x34. Actual: String(42).charCodeAt(void 0) ===' + String(42).charCodeAt(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.js new file mode 100644 index 0000000000..fa466e9cac --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T9 +description: > + Call charCodeAt() function with function(){}() argument of string + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (new String(42).charCodeAt(function() {}()) !== 0x34) { + throw new Test262Error('#1: new String(42).charCodeAt(function(){}()) === 0x34. Actual: new String(42).charCodeAt(function(){}()) ===' + new String(42).charCodeAt(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js new file mode 100644 index 0000000000..e7e04ab7f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.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: | + When String.prototype.charCodeAt(pos) calls if ToInteger(pos) less than 0 + the NaN returns +es5id: 15.5.4.5_A2 +description: Call charCodeAt(pos) with negative pos +---*/ + +function __FACTORY() {}; + +__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; + +var __instance = new __FACTORY; + +assert.sameValue(__instance.charCodeAt(-1), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.js new file mode 100644 index 0000000000..5ac83b6a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String.prototype.charCodeAt(pos) calls if ToInteger(pos) not less + than ToString(this value) the NaN returns +es5id: 15.5.4.5_A3 +description: pos is bigger of string length +---*/ + +var __instance = new String("ABC"); + +assert.sameValue(__instance.charCodeAt(3), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.js new file mode 100644 index 0000000000..3b74114d7f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String.prototype.charCodeAt(pos) calls first calls ToString, giving + it the this value as its argument +es5id: 15.5.4.5_A4 +description: Change toString function, it trow exception, and call charCodeAt() +---*/ + +var __obj = { + valueOf: 1, + toString: function() { + throw 'intostring' + }, + charCodeAt: String.prototype.charCodeAt +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.charCodeAt(); + throw new Test262Error('#1: "var x = __obj.charCodeAt()" lead to throwing exception'); +} catch (e) { + if (e !== 'intostring') { + throw new Test262Error('#1.1: Exception === \'intostring\'. Actual: exception ===' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.js new file mode 100644 index 0000000000..b5b9cbef8a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.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.prototype.charCodeAt has not prototype property +es5id: 15.5.4.5_A6 +description: Checking String.prototype.charCodeAt.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.charCodeAt.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.charCodeAt.prototype === undefined. Actual: ' + String.prototype.charCodeAt.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.js new file mode 100644 index 0000000000..be97cc320c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.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. + +/*--- +info: String.prototype.charCodeAt can't be used as constructor +es5id: 15.5.4.5_A7 +description: Checking if creating the String.prototype.charCodeAt object fails +---*/ + +var __FACTORY = String.prototype.charCodeAt; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.charCodeAt; "__instance = new __FACTORY" 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/prototype/charCodeAt/S15.5.4.5_A8.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A8.js new file mode 100644 index 0000000000..d62fdb38ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A8.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The String.prototype.charCodeAt.length property has the attribute DontEnum +es5id: 15.5.4.5_A8 +description: > + Checking if enumerating the String.prototype.charCodeAt.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.charCodeAt.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.charCodeAt.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.charCodeAt.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.charCodeAt) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.charCodeAt){if (p==="length") count++;} count === 0. Actual: count ===' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js new file mode 100644 index 0000000000..28876dd07a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The String.prototype.charCodeAt.length property does not have the + attribute DontDelete +es5id: 15.5.4.5_A9 +description: > + Checking if deleting the String.prototype.charCodeAt.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.charCodeAt.length) { + throw new Test262Error('#1: delete String.prototype.charCodeAt.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.charCodeAt.length; String.prototype.charCodeAt.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js new file mode 100644 index 0000000000..9916d17abf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/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.3.2 +description: > + String.prototype.charCodeAt.name is "charCodeAt". +info: | + String.prototype.charCodeAt ( pos ) + + 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.prototype.charCodeAt.name, "charCodeAt"); + +verifyNotEnumerable(String.prototype.charCodeAt, "name"); +verifyNotWritable(String.prototype.charCodeAt, "name"); +verifyConfigurable(String.prototype.charCodeAt, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js new file mode 100644 index 0000000000..282fcb0b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js @@ -0,0 +1,35 @@ +// 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.prototype.charCodeAt 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.prototype.charCodeAt), + false, + 'isConstructor(String.prototype.charCodeAt) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.charCodeAt(); +}, '`new String.prototype.charCodeAt()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.js new file mode 100644 index 0000000000..3f30646ab3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +description: Error when attempting to coerce providec "pos" to a Number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var noCoerce = Object.create(null); + +assert.throws(TypeError, function() { + ''.charCodeAt(noCoerce); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js new file mode 100644 index 0000000000..8d41a2de81 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +description: Coercion of "pos" string value into number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var cCode = 99; + +assert.sameValue('abcd'.charCodeAt(' +00200.0000E-0002 '), cCode); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js new file mode 100644 index 0000000000..577d1e1fc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +description: Rounding of the provided "pos" number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, return +0. + 3. If number is +0, -0, +∞, or -∞, return number. + 4. Return the number value that is the same sign as number and whose + magnitude is floor(abs(number)). +---*/ + +var aCode = 97; +var bCode = 98; + +assert.sameValue('abc'.charCodeAt(-0.99999), aCode, '-0.99999'); +assert.sameValue('abc'.charCodeAt(-0.00001), aCode, '-0.00001'); +assert.sameValue('abc'.charCodeAt(0.00001), aCode, '0.00001'); +assert.sameValue('abc'.charCodeAt(0.99999), aCode, '0.99999'); +assert.sameValue('abc'.charCodeAt(1.00001), bCode, '1.00001'); +assert.sameValue('abc'.charCodeAt(1.99999), bCode, '1.99999'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..0215b3ba7d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.charcodeat +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var charCodeAt = String.prototype.charCodeAt; + +assert.sameValue(typeof charCodeAt, 'function'); + +assert.throws(TypeError, function() { + charCodeAt.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + charCodeAt.call(null, 0); +}, 'null'); + +reportCompare(0, 0); |