From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- js/src/tests/test262/built-ins/eval/browser.js | 0 .../test262/built-ins/eval/length-enumerable.js | 27 +++++++++++++++++++ .../built-ins/eval/length-non-configurable.js | 27 +++++++++++++++++++ .../test262/built-ins/eval/length-non-writable.js | 18 +++++++++++++ .../tests/test262/built-ins/eval/length-value.js | 15 +++++++++++ js/src/tests/test262/built-ins/eval/name.js | 28 +++++++++++++++++++ .../tests/test262/built-ins/eval/no-construct.js | 23 ++++++++++++++++ js/src/tests/test262/built-ins/eval/no-proto.js | 15 +++++++++++ .../test262/built-ins/eval/not-a-constructor.js | 31 ++++++++++++++++++++++ .../eval/private-identifiers-not-empty.js | 27 +++++++++++++++++++ js/src/tests/test262/built-ins/eval/prop-desc.js | 18 +++++++++++++ js/src/tests/test262/built-ins/eval/shell.js | 19 +++++++++++++ 12 files changed, 248 insertions(+) create mode 100644 js/src/tests/test262/built-ins/eval/browser.js create mode 100644 js/src/tests/test262/built-ins/eval/length-enumerable.js create mode 100644 js/src/tests/test262/built-ins/eval/length-non-configurable.js create mode 100644 js/src/tests/test262/built-ins/eval/length-non-writable.js create mode 100644 js/src/tests/test262/built-ins/eval/length-value.js create mode 100644 js/src/tests/test262/built-ins/eval/name.js create mode 100644 js/src/tests/test262/built-ins/eval/no-construct.js create mode 100644 js/src/tests/test262/built-ins/eval/no-proto.js create mode 100644 js/src/tests/test262/built-ins/eval/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js create mode 100644 js/src/tests/test262/built-ins/eval/prop-desc.js create mode 100644 js/src/tests/test262/built-ins/eval/shell.js (limited to 'js/src/tests/test262/built-ins/eval') diff --git a/js/src/tests/test262/built-ins/eval/browser.js b/js/src/tests/test262/built-ins/eval/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/eval/length-enumerable.js b/js/src/tests/test262/built-ins/eval/length-enumerable.js new file mode 100644 index 0000000000..dbdce9ddd5 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/length-enumerable.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of eval has the attribute DontEnum +esid: sec-eval-x +description: Checking use propertyIsEnumerable, for-in +---*/ + +//CHECK#1 +if (eval.propertyIsEnumerable('length') !== false) { + $ERROR('#1: eval.propertyIsEnumerable(\'length\') === false. Actual: ' + (eval.propertyIsEnumerable('length'))); +} + +//CHECK#2 +var result = true; +for (p in eval) { + if (p === "length") { + result = false; + } +} + +if (result !== true) { + $ERROR('#2: result = true; for (p in eval) { if (p === "length") result = false; }; result === true;'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/length-non-configurable.js b/js/src/tests/test262/built-ins/eval/length-non-configurable.js new file mode 100644 index 0000000000..c55cb77add --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/length-non-configurable.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of eval does not have the attribute DontDelete +esid: sec-eval-x +description: Checking use hasOwnProperty, delete +---*/ + +//CHECK#1 +if (eval.hasOwnProperty('length') !== true) { + $ERROR('#1: eval.hasOwnProperty(\'length\') === true. Actual: ' + (eval.hasOwnProperty('length'))); +} + +delete eval.length; + +//CHECK#2 +if (eval.hasOwnProperty('length') !== false) { + $ERROR('#2: delete eval.length; eval.hasOwnProperty(\'length\') === false. Actual: ' + (eval.hasOwnProperty('length'))); +} + +//CHECK#3 +if (eval.length === undefined) { + $ERROR('#3: delete eval.length; eval.length !== undefined'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/length-non-writable.js b/js/src/tests/test262/built-ins/eval/length-non-writable.js new file mode 100644 index 0000000000..d48689fc92 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/length-non-writable.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of eval has the attribute ReadOnly +esid: sec-eval-x +description: Checking if varying the length property fails +includes: [propertyHelper.js] +---*/ + +//CHECK#1 +var x = eval.length; +verifyNotWritable(eval, "length", null, Infinity); +if (eval.length !== x) { + $ERROR('#1: x = eval.length; eval.length = Infinity; eval.length === x. Actual: ' + (eval.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/length-value.js b/js/src/tests/test262/built-ins/eval/length-value.js new file mode 100644 index 0000000000..755a943262 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/length-value.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of eval is 1 +esid: sec-eval-x +description: eval.length === 1 +---*/ + +//CHECK#1 +if (eval.length !== 1) { + $ERROR('#1: eval.length === 1. Actual: ' + (eval.length)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/name.js b/js/src/tests/test262/built-ins/eval/name.js new file mode 100644 index 0000000000..c69687839b --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-eval-x +description: > + eval.name is "eval". +info: | + eval (x) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(eval.name, "eval"); + +verifyNotEnumerable(eval, "name"); +verifyNotWritable(eval, "name"); +verifyConfigurable(eval, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/no-construct.js b/js/src/tests/test262/built-ins/eval/no-construct.js new file mode 100644 index 0000000000..12c9d656ef --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/no-construct.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The eval property can't be used as constructor +esid: sec-eval-x +description: > + If property does not implement the internal [[Construct]] method, + throw a TypeError exception +---*/ + +//CHECK#1 + +try { + new eval(); + $ERROR('#1.1: new eval() throw TypeError. Actual: ' + (new eval())); +} catch (e) { + if ((e instanceof TypeError) !== true) { + $ERROR('#1.2: new eval() throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/no-proto.js b/js/src/tests/test262/built-ins/eval/no-proto.js new file mode 100644 index 0000000000..a384d2e9b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/no-proto.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The eval property has not prototype property +esid: sec-eval-x +description: Checking eval.prototype +---*/ + +//CHECK#1 +if (eval.prototype !== undefined) { + $ERROR('#1: eval.prototype === undefined. Actual: ' + (eval.prototype)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/not-a-constructor.js b/js/src/tests/test262/built-ins/eval/not-a-constructor.js new file mode 100644 index 0000000000..e55f74de38 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + eval does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(eval), false, 'isConstructor(eval) must return false'); + +assert.throws(TypeError, () => { + new eval(''); +}, '`new eval(\'\')` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js b/js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js new file mode 100644 index 0000000000..00640c9563 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js @@ -0,0 +1,27 @@ +// |reftest| shell-option(--enable-private-fields) skip-if(!xulRuntime.shell) -- requires shell-options +// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-evaldeclarationinstantiation +description: EvalDeclarationInstantiation throws SyntaxError if there is some invalid private identifier on its body +info: | + EvalDeclarationInstantiation(body, varEnv, lexEnv, privateEnv, strict) + ... + 6. Let privateIdentifiers be an empty List. + 7. Let privateEnv be privateEnv. + 8. Repeat while privateEnv is not null, + a. For each binding named N in privateEnv, + i. If privateIdentifiers does not contain N, append N to privateIdentifiers. + b. Let privateEnv be privateEnv's outer environment reference. + 9. If AllPrivateIdentifiersValid of body with the argument privateIdentifiers is false, throw a SyntaxError exception. + ... +features: [class-fields-private] +---*/ + +assert.throws(SyntaxError, function() { + let o = {}; + eval("o.#f"); +}, 'It should be a SyntaxError if AllPrivateIdentifiersValid returns false to eval body'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/prop-desc.js b/js/src/tests/test262/built-ins/eval/prop-desc.js new file mode 100644 index 0000000000..4372703c83 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-eval-x +description: Property descriptor for eval +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "eval"); +verifyWritable(this, "eval"); +verifyConfigurable(this, "eval"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/eval/shell.js b/js/src/tests/test262/built-ins/eval/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/built-ins/eval/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} -- cgit v1.2.3