diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-and-value-of-function-that-throw-exception-second-object-have-overrided-value-of-function-that-throw-exception.js b/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-and-value-of-function-that-throw-exception-second-object-have-overrided-value-of-function-that-throw-exception.js deleted file mode 100644 index 26c5dc0e74..0000000000 --- a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-and-value-of-function-that-throw-exception-second-object-have-overrided-value-of-function-that-throw-exception.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2009 the Sputnik authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: | - String.prototype.split(separator, limit): - i) can be transferred to other kinds of objects for use as a method. - separator and limit can be any kinds of object since: - ii) if separator is not RegExp ToString(separator) performs and - iii) ToInteger(limit) performs -es5id: 15.5.4.14_A1_T15 -description: > - Arguments are objects, and instance is string. First object have - overrided toString function and valueOf function, that throw - exception. Second object have overrided valueOf function, that - throw exception ----*/ - -var __obj = { - toString: function() { - return {}; - }, - valueOf: function() { - throw "intostr"; - } -}; - -var __obj2 = { - valueOf: function() { - throw "intointeger"; - } -}; - -__FACTORY.prototype.split = String.prototype.split; - -var __instance = new __FACTORY(void 0); - -////////////////////////////////////////////////////////////////////////////// -//CHECK#1 -try { - var x = __instance.split(__obj, __obj2); - Test262Error.thrower('#1: "var x = __instance.split(__obj, __obj2)" lead to throwing exception'); -} catch (e) { - assert.sameValue(e, "intointeger", 'The value of `e` is "intointeger"'); -} -// -////////////////////////////////////////////////////////////////////////////// - -function __FACTORY(value) { - this.value = value; - this.toString = function() { - return new Number; - }; - this.valueOf = function() { - return this.value + "" - }; -} diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function-that-throw-exception.js b/test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-throws.js similarity index 100% rename from test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function-that-throw-exception.js rename to test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-throws.js diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function-and-to-string-function-that-throw-exception.js b/test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring-throws.js similarity index 100% rename from test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function-and-to-string-function-that-throw-exception.js rename to test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring-throws.js diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-and-to-string-functions.js b/test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring.js similarity index 100% rename from test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-and-to-string-functions.js rename to test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring.js diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function.js b/test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof.js similarity index 100% rename from test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-second-object-have-overrided-value-of-function.js rename to test/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof.js diff --git a/test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-that-throw-exception-second-object-have-overrided-value-of-function-that-throw-exception.js b/test/built-ins/String/prototype/split/separator-override-tostring-throws-limit-override-valueof-throws.js similarity index 100% rename from test/built-ins/String/prototype/split/arguments-are-objects-and-instance-is-string-first-object-have-overrided-to-string-function-that-throw-exception-second-object-have-overrided-value-of-function-that-throw-exception.js rename to test/built-ins/String/prototype/split/separator-override-tostring-throws-limit-override-valueof-throws.js diff --git a/test/built-ins/String/prototype/split/argument-is-function-and-instance-is-string-object-object-have-overrided-to-string-and-value-of-functions.js b/test/built-ins/String/prototype/split/separator-override-valueof.js similarity index 100% rename from test/built-ins/String/prototype/split/argument-is-function-and-instance-is-string-object-object-have-overrided-to-string-and-value-of-functions.js rename to test/built-ins/String/prototype/split/separator-override-valueof.js diff --git a/test/built-ins/String/prototype/split/transferred-to-custom.js b/test/built-ins/String/prototype/split/transferred-to-custom.js new file mode 100644 index 0000000000..91ed914d17 --- /dev/null +++ b/test/built-ins/String/prototype/split/transferred-to-custom.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.split +description: > + split method can be "transferred" to another object + whose this value can be coerced to a string. +info: | + String.prototype.split(separator, limit): + + Let O be ? RequireObjectCoercible(this value). + ... + Let S be ? ToString(O). + +includes: [compareArray.js] +---*/ + + +function Splittable(value) { + this.toString = function() { + return value + ""; + }; + this.valueOf = function() { + throw new Test262Error(); + }; +} + +Splittable.prototype.split = String.prototype.split; + +let splittable = new Splittable(void 0); + +assert.compareArray(splittable.split(""), ["u","n","d","e","f","i","n","e","d"]); diff --git a/test/built-ins/String/prototype/split/argument-is-object-and-instance-is-number-object-have-overrided-to-string-function-that-return-regexp.js b/test/built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js similarity index 100% rename from test/built-ins/String/prototype/split/argument-is-object-and-instance-is-number-object-have-overrided-to-string-function-that-return-regexp.js rename to test/built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js diff --git a/test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js b/test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js new file mode 100644 index 0000000000..b2c864e320 --- /dev/null +++ b/test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.split +description: > + Calls valueOf() of limit argument +info: | + String.prototype.split(separator, limit): + + If limit is undefined, let lim be 232 - 1; else let lim be ℝ(? ToUint32(limit)). +features: [arrow-function] +---*/ + + +let limit = { + toString() {}, + valueOf() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, () => { + "".split("", limit); +});