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/RegExp/prototype/hasIndices | |
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/RegExp/prototype/hasIndices')
10 files changed, 279 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/browser.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/browser.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/cross-realm.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/cross-realm.js new file mode 100644 index 0000000000..93d85a4160 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/cross-realm.js @@ -0,0 +1,31 @@ +// Copyright (C) 2021 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasindices +description: Invoked on a cross-realm object +info: | + get RegExp.prototype.hasIndices + + 1. Let R be the this value. + 2. If Type(R) is not Object, throw a TypeError exception. + 3. If R does not have an [[OriginalFlags]] internal slot, then + a. If SameValue(R, %RegExpPrototype%) is true, return undefined. + b. Otherwise, throw a TypeError exception. +features: [regexp-match-indices, cross-realm] +---*/ + +var hasIndices = Object.getOwnPropertyDescriptor(RegExp.prototype, 'hasIndices').get; +var other = $262.createRealm().global; +var otherRegExpProto = other.RegExp.prototype; +var otherRegExpGetter = Object.getOwnPropertyDescriptor(otherRegExpProto, 'hasIndices').get; + +assert.throws(TypeError, function() { + hasIndices.call(otherRegExpProto); +}, 'cross-realm RegExp.prototype'); + +assert.throws(other.TypeError, function() { + otherRegExpGetter.call(RegExp.prototype); +}, 'cross-realm RegExp.prototype getter method against primary realm RegExp.prototype'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/length.js new file mode 100644 index 0000000000..2a6c54f440 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/length.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Ron Buckton and André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasindices +description: > + get RegExp.prototype.hasIndices.length is 0. +info: | + get RegExp.prototype.hasIndices + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [regexp-match-indices] +---*/ + +var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "hasIndices"); + +assert.sameValue(desc.get.length, 0); + +verifyProperty(desc.get, "length", { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/name.js new file mode 100644 index 0000000000..9649fd3133 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Ron buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-regexp.prototype.hasindices +description: > + RegExp.prototype.hasIndices name +info: | + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. +includes: [propertyHelper.js] +features: [regexp-match-indices] +---*/ + +var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "hasIndices"); + +assert.sameValue( + desc.get.name, + "get hasIndices" +); + +verifyProperty(desc.get, "name", { + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/prop-desc.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/prop-desc.js new file mode 100644 index 0000000000..27a593b5c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/prop-desc.js @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-regexp.prototype.hasIndices +description: > + `pending` property descriptor +info: | + RegExp.prototype.hasIndices is an accessor property whose set accessor + function is undefined. + + 17 ECMAScript Standard Built-in Objects + + Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes + { [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. If only a get + accessor function is described, the set accessor function is the default value, undefined. If + only a set accessor is described the get accessor is the default value, undefined. +includes: [propertyHelper.js] +features: [regexp-match-indices] +---*/ + +var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "hasIndices"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyProperty(RegExp.prototype, "hasIndices", { + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/shell.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/shell.js diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-invalid-obj.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-invalid-obj.js new file mode 100644 index 0000000000..44bb0c8880 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-invalid-obj.js @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasindices +description: Invoked on an object without an [[OriginalFlags]] internal slot +info: | + get RegExp.prototype.hasIndices + + 1. Let R be the this value. + 2. If Type(R) is not Object, throw a TypeError exception. + 3. If R does not have an [[OriginalFlags]] internal slot, then + a. If SameValue(R, %RegExpPrototype%) is true, return undefined. + b. Otherwise, throw a TypeError exception. +features: [regexp-match-indices] +---*/ + +var hasIndices = Object.getOwnPropertyDescriptor(RegExp.prototype, 'hasIndices').get; + +assert.throws(TypeError, function() { + hasIndices.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + hasIndices.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + hasIndices.call(arguments); +}, 'arguments object'); + +assert.throws(TypeError, function() { + hasIndices.call(() => {}); +}, 'function object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-non-obj.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-non-obj.js new file mode 100644 index 0000000000..ac6f7d78e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-non-obj.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasindices +description: > + `hasIndices` accessor invoked on a non-object value +info: | + get RegExp.prototype.hasIndices + + 1. Let R be the this value. + 2. If Type(R) is not Object, throw a TypeError exception. +features: [Symbol, regexp-match-indices] +---*/ + +var hasIndices = Object.getOwnPropertyDescriptor(RegExp.prototype, "hasIndices").get; + +assert.throws(TypeError, function() { + hasIndices.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + hasIndices.call(null); +}, "null"); + +assert.throws(TypeError, function() { + hasIndices.call(true); +}, "true"); + +assert.throws(TypeError, function() { + hasIndices.call("string"); +}, "string"); + +assert.throws(TypeError, function() { + hasIndices.call(Symbol("s")); +}, "symbol"); + +assert.throws(TypeError, function() { + hasIndices.call(4); +}, "number"); + +assert.throws(TypeError, function() { + hasIndices.call(4n); +}, "bigint"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp-prototype.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp-prototype.js new file mode 100644 index 0000000000..8bdd4394c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp-prototype.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasIndices +description: > + Return value of `undefined` when the "this" value is the RegExp prototype + object +info: | + 1. Let R be the this value. + 2. If Type(R) is not Object, throw a TypeError exception. + 3. If R does not have an [[OriginalFlags]] internal slot, then + a. If SameValue(R, %RegExpPrototype%) is true, return undefined. +features: [regexp-match-indices] +---*/ + +var get = Object.getOwnPropertyDescriptor(RegExp.prototype, "hasIndices").get; + +assert.sameValue(get.call(RegExp.prototype), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp.js b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp.js new file mode 100644 index 0000000000..b029c46a47 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/prototype/hasIndices/this-val-regexp.js @@ -0,0 +1,49 @@ +// Copyright (C) 2021 Ron Buckton and the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-regexp.prototype.hasindices +description: > + `hasIndices` accessor function invoked on a RegExp instance +info: | + 21.2.5.12 get RegExp.prototype.hasIndices + + 4. Let flags be the value of R’s [[OriginalFlags]] internal slot. + 5. If flags contains the code unit "s", return true. + 6. Return false. +features: [regexp-match-indices] +---*/ + +assert.sameValue(/./.hasIndices, false, "/./.hasIndices"); +assert.sameValue(/./i.hasIndices, false, "/./i.hasIndices"); +assert.sameValue(/./g.hasIndices, false, "/./g.hasIndices"); +assert.sameValue(/./y.hasIndices, false, "/./y.hasIndices"); +assert.sameValue(/./m.hasIndices, false, "/./m.hasIndices"); +assert.sameValue(/./s.hasIndices, false, "/./s.hasIndices"); +assert.sameValue(/./u.hasIndices, false, "/./u.hasIndices"); + +assert.sameValue(/./d.hasIndices, true, "/./d.hasIndices"); +assert.sameValue(/./di.hasIndices, true, "/./di.hasIndices"); +assert.sameValue(/./dg.hasIndices, true, "/./dg.hasIndices"); +assert.sameValue(/./dy.hasIndices, true, "/./dy.hasIndices"); +assert.sameValue(/./dm.hasIndices, true, "/./dm.hasIndices"); +assert.sameValue(/./ds.hasIndices, true, "/./ds.hasIndices"); +assert.sameValue(/./du.hasIndices, true, "/./du.hasIndices"); + +assert.sameValue(new RegExp(".", "").hasIndices, false, "new RegExp('.', '').hasIndices"); +assert.sameValue(new RegExp(".", "i").hasIndices, false, "new RegExp('.', 'i').hasIndices"); +assert.sameValue(new RegExp(".", "g").hasIndices, false, "new RegExp('.', 'g').hasIndices"); +assert.sameValue(new RegExp(".", "y").hasIndices, false, "new RegExp('.', 'y').hasIndices"); +assert.sameValue(new RegExp(".", "m").hasIndices, false, "new RegExp('.', 'm').hasIndices"); +assert.sameValue(new RegExp(".", "s").hasIndices, false, "new RegExp('.', 's').hasIndices"); +assert.sameValue(new RegExp(".", "u").hasIndices, false, "new RegExp('.', 'u').hasIndices"); + +assert.sameValue(new RegExp(".", "d").hasIndices, true, "new RegExp('.', 'd').hasIndices"); +assert.sameValue(new RegExp(".", "di").hasIndices, true, "new RegExp('.', 'di').hasIndices"); +assert.sameValue(new RegExp(".", "dg").hasIndices, true, "new RegExp('.', 'dg').hasIndices"); +assert.sameValue(new RegExp(".", "dy").hasIndices, true, "new RegExp('.', 'dy').hasIndices"); +assert.sameValue(new RegExp(".", "dm").hasIndices, true, "new RegExp('.', 'dm').hasIndices"); +assert.sameValue(new RegExp(".", "ds").hasIndices, true, "new RegExp('.', 'ds').hasIndices"); +assert.sameValue(new RegExp(".", "du").hasIndices, true, "new RegExp('.', 'du').hasIndices"); + +reportCompare(0, 0); |