summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Symbol/prototype/valueOf
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/Symbol/prototype/valueOf
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/Symbol/prototype/valueOf')
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js32
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js29
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/prop-desc.js20
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-non-obj.js31
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-non-symbol.js28
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-symbol.js21
-rw-r--r--js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-symbol.js17
10 files changed, 213 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/browser.js
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js
new file mode 100644
index 0000000000..0134f86d03
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/length.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 19.4.3.3
+description: >
+ Symbol.prototype.valueOf.length is 0.
+info: |
+ Symbol.prototype.valueOf ( )
+
+ 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: [Symbol]
+---*/
+
+assert.sameValue(Symbol.prototype.valueOf.length, 0);
+
+verifyNotEnumerable(Symbol.prototype.valueOf, "length");
+verifyNotWritable(Symbol.prototype.valueOf, "length");
+verifyConfigurable(Symbol.prototype.valueOf, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js
new file mode 100644
index 0000000000..a9104cd8a8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/name.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 19.4.3.3
+description: >
+ Symbol.prototype.valueOf.name is "valueOf".
+info: |
+ Symbol.prototype.valueOf ( )
+
+ 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]
+features: [Symbol]
+---*/
+
+assert.sameValue(Symbol.prototype.valueOf.name, "valueOf");
+
+verifyNotEnumerable(Symbol.prototype.valueOf, "name");
+verifyNotWritable(Symbol.prototype.valueOf, "name");
+verifyConfigurable(Symbol.prototype.valueOf, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js
new file mode 100644
index 0000000000..e9edf778b8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/not-a-constructor.js
@@ -0,0 +1,35 @@
+// 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: >
+ Symbol.prototype.valueOf 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, Symbol, arrow-function]
+---*/
+
+assert.sameValue(
+ isConstructor(Symbol.prototype.valueOf),
+ false,
+ 'isConstructor(Symbol.prototype.valueOf) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let symbol = Symbol(); new symbol.valueOf();
+}, '`let symbol = Symbol(); new symbol.valueOf()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/prop-desc.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/prop-desc.js
new file mode 100644
index 0000000000..765157b4be
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/prop-desc.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-symbol.prototype.valueof
+description: Property descriptor
+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]
+features: [Symbol]
+---*/
+
+assert.sameValue(typeof Symbol.prototype.valueOf, 'function');
+
+verifyNotEnumerable(Symbol.prototype, 'valueOf');
+verifyWritable(Symbol.prototype, 'valueOf');
+verifyConfigurable(Symbol.prototype, 'valueOf');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/shell.js
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-non-obj.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-non-obj.js
new file mode 100644
index 0000000000..fe5ee15166
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-non-obj.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-symbol.prototype.valueof
+description: Called on a value that is neither a Symbol nor an Object
+info: |
+ 1. Let s be the this value.
+ 2. If Type(s) is Symbol, return s.
+ 3. If Type(s) is not Object, throw a TypeError exception.
+features: [Symbol]
+---*/
+
+var valueOf = Symbol.prototype.valueOf;
+
+assert.throws(TypeError, function() {
+ valueOf.call(null);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ valueOf.call(undefined);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ valueOf.call(0);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ valueOf.call('');
+}, 'string');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-non-symbol.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-non-symbol.js
new file mode 100644
index 0000000000..876780fb86
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-non-symbol.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-symbol.prototype.valueof
+description: Called on an Object value that is not a Symbol object
+info: |
+ 1. Let s be the this value.
+ 2. If Type(s) is Symbol, return s.
+ 3. If Type(s) is not Object, throw a TypeError exception.
+ 4. If s does not have a [[SymbolData]] internal slot, throw a TypeError exception.
+features: [Symbol]
+---*/
+
+var valueOf = Symbol.prototype.valueOf;
+
+assert.throws(TypeError, function() {
+ valueOf.call({});
+}, 'ordinary object');
+
+assert.throws(TypeError, function() {
+ valueOf.call([]);
+}, 'array exotic object');
+
+assert.throws(TypeError, function() {
+ valueOf.call(arguments);
+}, 'arguments exotic object');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-symbol.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-symbol.js
new file mode 100644
index 0000000000..1a992371b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-obj-symbol.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-symbol.prototype.valueof
+description: Called on a Symbol Object value
+info: |
+ 1. Let s be the this value.
+ 2. If Type(s) is Symbol, return s.
+ 3. If Type(s) is not Object, throw a TypeError exception.
+ 4. If s does not have a [[SymbolData]] internal slot, throw a TypeError exception.
+ 5. Return the value of s's [[SymbolData]] internal slot.
+features: [Symbol]
+---*/
+
+var valueOf = Symbol.prototype.valueOf;
+var symbol = Symbol('s');
+var symbolObject = Object(symbol);
+
+assert.sameValue(valueOf.call(symbolObject), symbol);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-symbol.js b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-symbol.js
new file mode 100644
index 0000000000..7bea7e00e0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-symbol.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-symbol.prototype.valueof
+description: Called on a Symbol value
+info: |
+ 1. Let s be the this value.
+ 2. If Type(s) is Symbol, return s.
+features: [Symbol]
+---*/
+
+var valueOf = Symbol.prototype.valueOf;
+var subject = Symbol('s');
+
+assert.sameValue(valueOf.call(subject), subject);
+
+reportCompare(0, 0);