diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js new file mode 100644 index 0000000000..dca75da974 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/concat/Array.prototype.concat_spreadable-reg-exp.js @@ -0,0 +1,41 @@ +// Copyright (c) 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable reg exp +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var re = /abc/; +// RegExps are not concat-spreadable by default +assert.compareArray([].concat(re), [re], '[].concat(/abc/) must return [re]'); + +// RegExps may be individually concat-spreadable +re[Symbol.isConcatSpreadable] = true; +re[0] = 1, re[1] = 2, re[2] = 3, re.length = 3; +assert.compareArray([].concat(re), [1, 2, 3], '[].concat(/abc/) must return [1, 2, 3]'); + +// RegExps may be concat-spreadable +RegExp.prototype[Symbol.isConcatSpreadable] = true; +RegExp.prototype.length = 3; + +assert.compareArray([].concat(/abc/), [void 0, void 0, void 0], + '[].concat(/abc/) must return [void 0, void 0, void 0]' +); +RegExp.prototype[0] = 1; +RegExp.prototype[1] = 2; +RegExp.prototype[2] = 3; +assert.compareArray([].concat(/abc/), [1, 2, 3], + '[].concat(/abc/) must return [1, 2, 3]' +); + +delete RegExp.prototype[Symbol.isConcatSpreadable]; +delete RegExp.prototype[0]; +delete RegExp.prototype[1]; +delete RegExp.prototype[2]; +delete RegExp.prototype.length; + +reportCompare(0, 0); |