diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js')
-rw-r--r-- | js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js new file mode 100644 index 0000000000..3d5a6f9cc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js @@ -0,0 +1,59 @@ +// 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: Separator is a regexp +info: | + String.prototype.split ( separator, limit ) + + If separator is neither undefined nor null, then + Let splitter be ? GetMethod(separator, @@split). + If splitter is not undefined, then + Return ? Call(splitter, separator, « O, limit »). + + RegExp.prototype [ @@split ] ( string, limit ) + + Let C be ? SpeciesConstructor(rx, %RegExp%). + +includes: [compareArray.js] +---*/ + +assert.compareArray("x".split(/^/), ["x"], '"x".split(/^/) must return ["x"]'); +assert.compareArray("x".split(/$/), ["x"], '"x".split(/$/) must return ["x"]'); +assert.compareArray("x".split(/.?/), ["", ""], '"x".split(/.?/) must return ["", ""]'); +assert.compareArray("x".split(/.*/), ["", ""], '"x".split(/.*/) must return ["", ""]'); +assert.compareArray("x".split(/.+/), ["", ""], '"x".split(/.+/) must return ["", ""]'); +assert.compareArray("x".split(/.*?/), ["x"], '"x".split(/.*?/) must return ["x"]'); +assert.compareArray("x".split(/.{1}/), ["", ""], '"x".split(/.{1}/) must return ["", ""]'); +assert.compareArray("x".split(/.{1,}/), ["", ""], '"x".split(/.{1,}/) must return ["", ""]'); +assert.compareArray("x".split(/.{1,2}/), ["", ""], '"x".split(/.{1,2}/) must return ["", ""]'); +assert.compareArray("x".split(/()/), ["x"], '"x".split(/()/) must return ["x"]'); +assert.compareArray("x".split(/./), ["",""], '"x".split(/./) must return ["",""]'); +assert.compareArray("x".split(/(?:)/), ["x"], '"x".split(/(?:)/) must return ["x"]'); +assert.compareArray("x".split(/(...)/), ["x"], '"x".split(/(...)/) must return ["x"]'); +assert.compareArray("x".split(/(|)/), ["x"], '"x".split(/(|)/) must return ["x"]'); +assert.compareArray("x".split(/[]/), ["x"], '"x".split(/[]/) must return ["x"]'); +assert.compareArray("x".split(/[^]/), ["", ""], '"x".split(/[^]/) must return ["", ""]'); +assert.compareArray("x".split(/[.-.]/), ["x"], '"x".split(/[.-.]/) must return ["x"]'); +assert.compareArray("x".split(/\0/), ["x"], '"x".split(/\\0/) must return ["x"]'); +assert.compareArray("x".split(/\b/), ["x"], '"x".split(/\\b/) must return ["x"]'); +assert.compareArray("x".split(/\B/), ["x"], '"x".split(/\\B/) must return ["x"]'); +assert.compareArray("x".split(/\d/), ["x"], '"x".split(/\\d/) must return ["x"]'); +assert.compareArray("x".split(/\D/), ["", ""], '"x".split(/\\D/) must return ["", ""]'); +assert.compareArray("x".split(/\n/), ["x"], '"x".split(/\\n/) must return ["x"]'); +assert.compareArray("x".split(/\r/), ["x"], '"x".split(/\\r/) must return ["x"]'); +assert.compareArray("x".split(/\s/), ["x"], '"x".split(/\\s/) must return ["x"]'); +assert.compareArray("x".split(/\S/), ["", ""], '"x".split(/\\S/) must return ["", ""]'); +assert.compareArray("x".split(/\v/), ["x"], '"x".split(/\\v/) must return ["x"]'); +assert.compareArray("x".split(/\w/), ["", ""], '"x".split(/\\w/) must return ["", ""]'); +assert.compareArray("x".split(/\W/), ["x"], '"x".split(/\\W/) must return ["x"]'); +assert.compareArray("x".split(/\k<x>/), ["x"], '"x".split(/\\k<x>/) must return ["x"]'); +assert.compareArray("x".split(/\xA0/), ["x"], '"x".split(/\\xA0/) must return ["x"]'); +assert.compareArray("x".split(/\XA0/), ["x"], '"x".split(/\\XA0/) must return ["x"]'); +assert.compareArray("x".split(/\ddd/), ["x"], '"x".split(/\\ddd/) must return ["x"]'); +assert.compareArray("x".split(/\cY/), ["x"], '"x".split(/\\cY/) must return ["x"]'); +assert.compareArray("x".split(/[\b]/), ["x"], '"x".split(/[\\b]/) must return ["x"]'); +assert.compareArray("x".split(/\x/), ["", ""], '"x".split(/\\x/) must return ["", ""]'); +assert.compareArray("x".split(/\X/), ["x"], '"x".split(/\\X/) must return ["x"]'); + +reportCompare(0, 0); |