summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Reflect/ownKeys
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Reflect/ownKeys')
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/length.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/name.js25
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/order-after-define-property.js52
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/ownKeys.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-abrupt-from-result.js28
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-array-with-own-keys-only.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-empty-array.js26
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-non-enumerable-keys.js40
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order-large-index.js82
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order.js56
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/shell.js19
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-not-object-throws.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-symbol-throws.js19
15 files changed, 480 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/browser.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/browser.js
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js
new file mode 100644
index 0000000000..7f84f0b49a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/length.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Reflect.ownKeys.length value and property descriptor
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.ownKeys.length, 1,
+ 'The value of `Reflect.ownKeys.length` is `1`'
+);
+
+verifyNotEnumerable(Reflect.ownKeys, 'length');
+verifyNotWritable(Reflect.ownKeys, 'length');
+verifyConfigurable(Reflect.ownKeys, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js
new file mode 100644
index 0000000000..77a757dfc5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/name.js
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Reflect.ownKeys.name value and property descriptor
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.ownKeys.name, 'ownKeys',
+ 'The value of `Reflect.ownKeys.name` is `"ownKeys"`'
+);
+
+verifyNotEnumerable(Reflect.ownKeys, 'name');
+verifyNotWritable(Reflect.ownKeys, 'name');
+verifyConfigurable(Reflect.ownKeys, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/not-a-constructor.js
new file mode 100644
index 0000000000..9419d7cdd5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/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: >
+ Reflect.ownKeys 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, Reflect, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Reflect.ownKeys), false, 'isConstructor(Reflect.ownKeys) must return false');
+
+assert.throws(TypeError, () => {
+ new Reflect.ownKeys({});
+}, '`new Reflect.ownKeys({})` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/order-after-define-property.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/order-after-define-property.js
new file mode 100644
index 0000000000..3d19d6e760
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/order-after-define-property.js
@@ -0,0 +1,52 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-reflect.ownkeys
+description: >
+ Property names are returned in ascending chronological order of creation
+ that is unaffected by [[DefineOwnProperty]].
+info: |
+ Reflect.ownKeys ( target )
+
+ [...]
+ 2. Let keys be ? target.[[OwnPropertyKeys]]().
+ 3. Return CreateArrayFromList(keys).
+
+ OrdinaryOwnPropertyKeys ( O )
+
+ [...]
+ 4. For each own property key P of O that is a Symbol, in ascending
+ chronological order of property creation, do
+ a. Add P as the last element of keys.
+ 5. Return keys.
+
+ [[OwnPropertyKeys]] ( )
+
+ [...]
+ 7. For each own property key P of O such that Type(P) is String and P is not
+ an array index, in ascending chronological order of property creation, do
+ a. Add P as the last element of keys.
+ [...]
+ 9. Return keys.
+features: [Symbol, Reflect]
+includes: [compareArray.js]
+---*/
+
+var obj = {};
+var symA = Symbol("a");
+var symB = Symbol("b");
+obj[symA] = 1;
+obj[symB] = 2;
+Object.defineProperty(obj, symA, {configurable: false});
+assert.compareArray(Reflect.ownKeys(obj), [symA, symB]);
+
+var str = new String("");
+str.a = 1;
+str.b = 2;
+Object.defineProperty(str, "a", {
+ get: function() {},
+});
+assert.compareArray(Reflect.ownKeys(str), ["length", "a", "b"]);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/ownKeys.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/ownKeys.js
new file mode 100644
index 0000000000..e647a73392
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/ownKeys.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Reflect.ownKeys is configurable, writable and not enumerable.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+verifyNotEnumerable(Reflect, 'ownKeys');
+verifyWritable(Reflect, 'ownKeys');
+verifyConfigurable(Reflect, 'ownKeys');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-abrupt-from-result.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-abrupt-from-result.js
new file mode 100644
index 0000000000..1f289fc732
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-abrupt-from-result.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Return abrupt result from target.[[OwnPropertyKeys]]()
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ ...
+features: [Proxy, Reflect]
+---*/
+
+var o = {};
+var p = new Proxy(o, {
+ ownKeys: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ Reflect.ownKeys(p);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-array-with-own-keys-only.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-array-with-own-keys-only.js
new file mode 100644
index 0000000000..0f3ae2f89e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-array-with-own-keys-only.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Returns target's own property keys only, ignore prototype keys.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ 4. Return CreateArrayFromList(keys).
+includes: [compareArray.js]
+features: [Reflect]
+---*/
+
+var proto = {
+ foo: 1
+};
+
+var o = Object.create(proto);
+o.p1 = 42;
+o.p2 = 43;
+o.p3 = 44;
+assert(
+ compareArray(Reflect.ownKeys(o), ['p1', 'p2', 'p3']),
+ 'return object own keys'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-empty-array.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-empty-array.js
new file mode 100644
index 0000000000..50bc231592
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-empty-array.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Returns empty array when target has no own properties.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ 4. Return CreateArrayFromList(keys).
+includes: [compareArray.js]
+features: [Reflect]
+---*/
+
+assert(compareArray(Reflect.ownKeys({}), []));
+
+var o = {
+ d: 42
+};
+delete o.d;
+assert(compareArray(Reflect.ownKeys(o), []));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-non-enumerable-keys.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-non-enumerable-keys.js
new file mode 100644
index 0000000000..0387bb22a0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-non-enumerable-keys.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Returns target's own non enumerable property keys.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ 4. Return CreateArrayFromList(keys).
+includes: [compareArray.js]
+features: [Reflect]
+---*/
+
+assert(
+ compareArray(Reflect.ownKeys([]), ['length']),
+ 'return non enumerable `length` from empty array'
+);
+
+assert(
+ compareArray(Reflect.ownKeys([, , 2]), ['2', 'length']),
+ 'return array keys'
+);
+
+var o = {};
+Object.defineProperty(o, 'p1', {
+ value: 42,
+ enumerable: false
+});
+Object.defineProperty(o, 'p2', {
+ get: function() {},
+ enumerable: false
+});
+
+assert(compareArray(Reflect.ownKeys(o), ['p1', 'p2']));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order-large-index.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order-large-index.js
new file mode 100644
index 0000000000..70ea65de92
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order-large-index.js
@@ -0,0 +1,82 @@
+// Copyright (C) 2018 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ordinaryownpropertykeys
+description: >
+ Returns keys in their corresponding order.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ 4. Return CreateArrayFromList(keys).
+
+ 9.1.12 [[OwnPropertyKeys]] ( )
+
+ 1. Let keys be a new empty List.
+ 2. For each own property key P of O that is an array index, in ascending
+ numeric index order
+ a. Add P as the last element of keys.
+ 3. For each own property key P of O that is a String but is not an array
+ index, in property creation order
+ a. Add P as the last element of keys.
+ 4. For each own property key P of O that is a Symbol, in property creation
+ order
+ a. Add P as the last element of keys.
+ 5. Return keys.
+features: [computed-property-names, Reflect, Symbol]
+---*/
+
+var o1 = {
+ 12345678900: true,
+ b: true,
+ 1: true,
+ a: true,
+ [Number.MAX_SAFE_INTEGER]: true,
+ [Symbol.for('z')]: true,
+ 12345678901: true,
+ 4294967294: true,
+ 4294967295: true,
+};
+
+var result = Reflect.ownKeys(o1);
+
+assert.sameValue(result.length, 9);
+assert.sameValue(result[0], '1');
+assert.sameValue(result[1], '4294967294');
+assert.sameValue(result[2], '12345678900');
+assert.sameValue(result[3], 'b');
+assert.sameValue(result[4], 'a');
+assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
+assert.sameValue(result[6], '12345678901');
+assert.sameValue(result[7], '4294967295');
+assert.sameValue(result[8], Symbol.for('z'));
+
+var o2 = {};
+
+o2[12345678900] = true;
+o2.b = true;
+o2[1] = true;
+o2.a = true;
+o2[Number.MAX_SAFE_INTEGER] = true;
+o2[Symbol.for('z')] = true;
+o2[12345678901] = true;
+o2[4294967294] = true;
+o2[4294967295] = true;
+
+
+result = Reflect.ownKeys(o2);
+
+assert.sameValue(result.length, 9);
+assert.sameValue(result[0], '1');
+assert.sameValue(result[1], '4294967294');
+assert.sameValue(result[2], '12345678900');
+assert.sameValue(result[3], 'b');
+assert.sameValue(result[4], 'a');
+assert.sameValue(result[5], String(Number.MAX_SAFE_INTEGER));
+assert.sameValue(result[6], '12345678901');
+assert.sameValue(result[7], '4294967295');
+assert.sameValue(result[8], Symbol.for('z'));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order.js
new file mode 100644
index 0000000000..5285fcf35a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/return-on-corresponding-order.js
@@ -0,0 +1,56 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Returns keys in their corresponding order.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ ...
+ 2. Let keys be target.[[OwnPropertyKeys]]().
+ 3. ReturnIfAbrupt(keys).
+ 4. Return CreateArrayFromList(keys).
+
+ 9.1.12 [[OwnPropertyKeys]] ( )
+
+ 1. Let keys be a new empty List.
+ 2. For each own property key P of O that is an integer index, in ascending
+ numeric index order
+ a. Add P as the last element of keys.
+ 3. For each own property key P of O that is a String but is not an integer
+ index, in property creation order
+ a. Add P as the last element of keys.
+ 4. For each own property key P of O that is a Symbol, in property creation
+ order
+ a. Add P as the last element of keys.
+ 5. Return keys.
+features: [Reflect, Symbol]
+---*/
+
+
+var o = {};
+o.p1 = 42;
+o.p2 = 43;
+
+var s1 = Symbol('1');
+var s2 = Symbol('a');
+o[s1] = 44;
+o[s2] = 45;
+
+o[2] = 46;
+o[0] = 47;
+o[1] = 48;
+
+var result = Reflect.ownKeys(o);
+
+assert.sameValue(result.length, 7);
+assert.sameValue(result[0], '0');
+assert.sameValue(result[1], '1');
+assert.sameValue(result[2], '2');
+assert.sameValue(result[3], 'p1');
+assert.sameValue(result[4], 'p2');
+assert.sameValue(result[5], s1);
+assert.sameValue(result[6], s2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/shell.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/shell.js
new file mode 100644
index 0000000000..54371b7789
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/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;
+}
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-not-object-throws.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-not-object-throws.js
new file mode 100644
index 0000000000..f894d475df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-not-object-throws.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Throws a TypeError if target is not an Object.
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.ownKeys(1);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.ownKeys(null);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.ownKeys(undefined);
+});
+
+assert.throws(TypeError, function() {
+ Reflect.ownKeys('');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-symbol-throws.js b/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-symbol-throws.js
new file mode 100644
index 0000000000..b033e21e08
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/ownKeys/target-is-symbol-throws.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 26.1.11
+description: >
+ Throws a TypeError if target is a Symbol
+info: |
+ 26.1.11 Reflect.ownKeys ( target )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect, Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.ownKeys(Symbol(1));
+});
+
+reportCompare(0, 0);