Update Symbol.split functions for String and Regexp to match new standard (#3942)

In newest ES standard limit parameter is calculated using
ToUint32 function instead of ToLength.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
This commit is contained in:
Rafal Walczyna
2020-06-30 16:03:11 +02:00
committed by GitHub
parent 3e866258db
commit 9d2b7334bc
6 changed files with 48 additions and 5 deletions
@@ -0,0 +1,20 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
result = /./[Symbol.split]('string', -13);
assert(result.length === 7);
result = /./[Symbol.split]('string', 2);
assert(result.length === 2);
@@ -13,11 +13,11 @@
// limitations under the License.
var str = "foo//bar/baz//foo";
res = str.split("a", Infinity);
res = str.split("a", -1);
assert (res.length === 3);
assert (res[0] === "foo//b");
assert (res[1] === "r/b");
assert (res[2] === "z//foo");
res = str.split(/\/\//, -1);
res = str.split(/\/\//, Infinity);
assert (res.length === 0);
+11
View File
@@ -107,3 +107,14 @@ try {
} catch (e) {
assert (e === "abrupt capture");
}
Object.defineProperty(RegExp.prototype, "exec", { value: function (str) {
this.lastIndex = 10;
return { };
}});
var result = split.call ({flags: "g"}, "string");
assert(result.length === 2)
assert(result[0] === "")
assert(result[1] === "")