summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/eval
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/eval
parentInitial commit. (diff)
downloadfirefox-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/eval')
-rw-r--r--js/src/tests/test262/built-ins/eval/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/eval/length-enumerable.js27
-rw-r--r--js/src/tests/test262/built-ins/eval/length-non-configurable.js27
-rw-r--r--js/src/tests/test262/built-ins/eval/length-non-writable.js18
-rw-r--r--js/src/tests/test262/built-ins/eval/length-value.js15
-rw-r--r--js/src/tests/test262/built-ins/eval/name.js28
-rw-r--r--js/src/tests/test262/built-ins/eval/no-construct.js22
-rw-r--r--js/src/tests/test262/built-ins/eval/no-proto.js15
-rw-r--r--js/src/tests/test262/built-ins/eval/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js26
-rw-r--r--js/src/tests/test262/built-ins/eval/prop-desc.js18
-rw-r--r--js/src/tests/test262/built-ins/eval/shell.js24
12 files changed, 251 insertions, 0 deletions
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
--- /dev/null
+++ b/js/src/tests/test262/built-ins/eval/browser.js
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..e04423ca81
--- /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) {
+ throw new Test262Error('#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) {
+ throw new Test262Error('#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..ba81e3dc12
--- /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) {
+ throw new Test262Error('#1: eval.hasOwnProperty(\'length\') === true. Actual: ' + (eval.hasOwnProperty('length')));
+}
+
+delete eval.length;
+
+//CHECK#2
+if (eval.hasOwnProperty('length') !== false) {
+ throw new Test262Error('#2: delete eval.length; eval.hasOwnProperty(\'length\') === false. Actual: ' + (eval.hasOwnProperty('length')));
+}
+
+//CHECK#3
+if (eval.length === undefined) {
+ throw new Test262Error('#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..10ba827844
--- /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) {
+ throw new Test262Error('#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..4252528710
--- /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) {
+ throw new Test262Error('#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..9c3bf75dc9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/eval/no-construct.js
@@ -0,0 +1,22 @@
+// 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();
+} catch (e) {
+ if ((e instanceof TypeError) !== true) {
+ throw new Test262Error('#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..6e58d5d938
--- /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) {
+ throw new Test262Error('#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..a352976049
--- /dev/null
+++ b/js/src/tests/test262/built-ins/eval/private-identifiers-not-empty.js
@@ -0,0 +1,26 @@
+// 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..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/eval/shell.js
@@ -0,0 +1,24 @@
+// 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]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}