From fd10123a719b1fbcd2d87eb95d661d90155f7382 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Mon, 19 Oct 2020 10:07:02 -0400 Subject: [PATCH] String.prototype.split: rename overlong files. Fixes gh-2865 --- ...-value-of-function-that-throw-exception.js | 57 ------------------- ...tostring-limit-override-valueof-throws.js} | 0 ...limit-override-valueof-tostring-throws.js} | 0 ...string-limit-override-valueof-tostring.js} | 0 ...erride-tostring-limit-override-valueof.js} | 0 ...g-throws-limit-override-valueof-throws.js} | 0 ...tions.js => separator-override-valueof.js} | 0 .../prototype/split/transferred-to-custom.js | 33 +++++++++++ ...rator-override-tostring-returns-regexp.js} | 0 .../valueOf-is-called-for-limit-argument.js | 25 ++++++++ 10 files changed, 58 insertions(+), 57 deletions(-) delete mode 100644 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 rename 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 => separator-override-tostring-limit-override-valueof-throws.js} (100%) rename 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 => separator-override-tostring-limit-override-valueof-tostring-throws.js} (100%) rename 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 => separator-override-tostring-limit-override-valueof-tostring.js} (100%) rename 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 => separator-override-tostring-limit-override-valueof.js} (100%) rename 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 => separator-override-tostring-throws-limit-override-valueof-throws.js} (100%) rename test/built-ins/String/prototype/split/{argument-is-function-and-instance-is-string-object-object-have-overrided-to-string-and-value-of-functions.js => separator-override-valueof.js} (100%) create mode 100644 test/built-ins/String/prototype/split/transferred-to-custom.js rename test/built-ins/String/prototype/split/{argument-is-object-and-instance-is-number-object-have-overrided-to-string-function-that-return-regexp.js => transferred-to-number-separator-override-tostring-returns-regexp.js} (100%) create mode 100644 test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js 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); +});