mirror of https://github.com/tc39/test262.git
String.prototype.split: rename overlong files. Fixes gh-2865
This commit is contained in:
parent
3439564fca
commit
fd10123a71
|
@ -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 + ""
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -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"]);
|
25
test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js
vendored
Normal file
25
test/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js
vendored
Normal file
|
@ -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);
|
||||||
|
});
|
Loading…
Reference in New Issue