summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Reflect/get
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Reflect/get')
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/get.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/length.js24
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/name.js25
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-property-key.js27
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-result.js32
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/return-value-from-receiver.js54
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/return-value-from-symbol-key.js29
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/return-value.js72
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/target-is-not-object-throws.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/get/target-is-symbol-throws.js19
13 files changed, 388 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Reflect/get/browser.js b/js/src/tests/test262/built-ins/Reflect/get/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/browser.js
diff --git a/js/src/tests/test262/built-ins/Reflect/get/get.js b/js/src/tests/test262/built-ins/Reflect/get/get.js
new file mode 100644
index 0000000000..ea85d09962
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/get.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.6
+description: >
+ Reflect.get is configurable, writable and not enumerable.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+verifyNotEnumerable(Reflect, 'get');
+verifyWritable(Reflect, 'get');
+verifyConfigurable(Reflect, 'get');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/length.js b/js/src/tests/test262/built-ins/Reflect/get/length.js
new file mode 100644
index 0000000000..615f35d6cc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/length.js
@@ -0,0 +1,24 @@
+// 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.6
+description: >
+ Reflect.get.length value and property descriptor
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ The length property of the get function is 2.
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.get.length, 2,
+ 'The value of `Reflect.get.length` is `2`'
+);
+
+verifyNotEnumerable(Reflect.get, 'length');
+verifyNotWritable(Reflect.get, 'length');
+verifyConfigurable(Reflect.get, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/name.js b/js/src/tests/test262/built-ins/Reflect/get/name.js
new file mode 100644
index 0000000000..d474d98e0f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/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.6
+description: >
+ Reflect.get.name value and property descriptor
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.get.name, 'get',
+ 'The value of `Reflect.get.name` is `"get"`'
+);
+
+verifyNotEnumerable(Reflect.get, 'name');
+verifyNotWritable(Reflect.get, 'name');
+verifyConfigurable(Reflect.get, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/get/not-a-constructor.js
new file mode 100644
index 0000000000..73635058ff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/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.get 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.get), false, 'isConstructor(Reflect.get) must return false');
+
+assert.throws(TypeError, () => {
+ new Reflect.get({}, '');
+}, '`new Reflect.get({}, \'\')` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-property-key.js b/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-property-key.js
new file mode 100644
index 0000000000..0fa8115530
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-property-key.js
@@ -0,0 +1,27 @@
+// 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.6
+description: >
+ Return abrupt from ToPropertyKey(propertyKey)
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ ...
+ 2. Let key be ToPropertyKey(propertyKey).
+ 3. ReturnIfAbrupt(key).
+ ...
+features: [Reflect]
+---*/
+
+var p = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ Reflect.get({}, p);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-result.js b/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-result.js
new file mode 100644
index 0000000000..10a86ac487
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/return-abrupt-from-result.js
@@ -0,0 +1,32 @@
+// 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.6
+description: >
+ Return abrupt result from get a property value.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ ...
+ 5. Return target.[[Get]](key, receiver).
+features: [Reflect]
+---*/
+
+var o1 = {};
+Object.defineProperty(o1, 'p1', {
+ get: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ Reflect.get(o1, 'p1');
+});
+
+// Abrupt from the prototype property
+var o2 = Object.create(o1);
+assert.throws(Test262Error, function() {
+ Reflect.get(o2, 'p1');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/return-value-from-receiver.js b/js/src/tests/test262/built-ins/Reflect/get/return-value-from-receiver.js
new file mode 100644
index 0000000000..fd5ece4ad9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/return-value-from-receiver.js
@@ -0,0 +1,54 @@
+// 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.6
+description: >
+ Return value from a receiver.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Get]](key, receiver).
+
+ 9.1.8 [[Get]] (P, Receiver)
+
+ ...
+ 2. Let desc be O.[[GetOwnProperty]](P).
+ 3. ReturnIfAbrupt(desc).
+ 4. If desc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is null, return undefined.
+ d. Return parent.[[Get]](P, Receiver).
+ 5. If IsDataDescriptor(desc) is true, return desc.[[Value]].
+ 6. Otherwise, IsAccessorDescriptor(desc) must be true so, let getter be
+ desc.[[Get]].
+ 7. If getter is undefined, return undefined.
+ 8. Return Call(getter, Receiver).
+features: [Reflect]
+---*/
+
+var o1 = {};
+var receiver = {
+ y: 42
+};
+
+Object.defineProperty(o1, 'x', {
+ get: function() {
+ return this.y;
+ }
+});
+assert.sameValue(
+ Reflect.get(o1, 'x', receiver), 42,
+ 'Return own property value using a receiver'
+);
+
+var o2 = Object.create(o1);
+assert.sameValue(
+ Reflect.get(o2, 'x', receiver), 42,
+ 'Return prototype property value using a receiver'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/return-value-from-symbol-key.js b/js/src/tests/test262/built-ins/Reflect/get/return-value-from-symbol-key.js
new file mode 100644
index 0000000000..7e1ddc25ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/return-value-from-symbol-key.js
@@ -0,0 +1,29 @@
+// 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.6
+description: >
+ Return value where property key is a symbol.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ ...
+ 2. Let key be ToPropertyKey(propertyKey).
+ ...
+
+ 7.1.14 ToPropertyKey ( argument )
+
+ ...
+ 3. If Type(key) is Symbol, then
+ a. Return key.
+ ...
+features: [Reflect, Symbol]
+---*/
+
+var o = {};
+var s = Symbol('1');
+o[s] = 42;
+
+assert.sameValue(Reflect.get(o, s), 42);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/return-value.js b/js/src/tests/test262/built-ins/Reflect/get/return-value.js
new file mode 100644
index 0000000000..0c4869cd4c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/return-value.js
@@ -0,0 +1,72 @@
+// 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.6
+description: >
+ Return value.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ ...
+ 4. If receiver is not present, then
+ a. Let receiver be target.
+ 5. Return target.[[Get]](key, receiver).
+
+ 9.1.8 [[Get]] (P, Receiver)
+
+ ...
+ 2. Let desc be O.[[GetOwnProperty]](P).
+ 3. ReturnIfAbrupt(desc).
+ 4. If desc is undefined, then
+ a. Let parent be O.[[GetPrototypeOf]]().
+ b. ReturnIfAbrupt(parent).
+ c. If parent is null, return undefined.
+ d. Return parent.[[Get]](P, Receiver).
+ 5. If IsDataDescriptor(desc) is true, return desc.[[Value]].
+ 6. Otherwise, IsAccessorDescriptor(desc) must be true so, let getter be
+ desc.[[Get]].
+ 7. If getter is undefined, return undefined.
+ 8. Return Call(getter, Receiver).
+features: [Reflect]
+---*/
+
+var o = {};
+
+o.p1 = 'value 1';
+assert.sameValue(
+ Reflect.get(o, 'p1'), 'value 1',
+ 'Return value from data descriptor'
+);
+
+Object.defineProperty(o, 'p2', {
+ get: undefined
+});
+assert.sameValue(
+ Reflect.get(o, 'p2'), undefined,
+ 'Return undefined if getter is undefined'
+);
+
+Object.defineProperty(o, 'p3', {
+ get: function() {
+ return 'foo';
+ }
+});
+assert.sameValue(
+ Reflect.get(o, 'p3'), 'foo',
+ 'Return Call(getter, Receiver)'
+);
+
+var o2 = Object.create({
+ p: 42
+});
+assert.sameValue(
+ Reflect.get(o2, 'p'), 42,
+ 'Return value from prototype without own property.'
+);
+
+assert.sameValue(
+ Reflect.get(o2, 'u'), undefined,
+ 'Return undefined without property on the object and its prototype'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/shell.js b/js/src/tests/test262/built-ins/Reflect/get/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/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;
+}
diff --git a/js/src/tests/test262/built-ins/Reflect/get/target-is-not-object-throws.js b/js/src/tests/test262/built-ins/Reflect/get/target-is-not-object-throws.js
new file mode 100644
index 0000000000..ea13d84414
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/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.6
+description: >
+ Throws a TypeError if target is not an Object.
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.get(1, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.get(null, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.get(undefined, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.get('', 'p');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/get/target-is-symbol-throws.js b/js/src/tests/test262/built-ins/Reflect/get/target-is-symbol-throws.js
new file mode 100644
index 0000000000..de683778ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/get/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.6
+description: >
+ Throws a TypeError if target is a Symbol
+info: |
+ 26.1.6 Reflect.get ( target, propertyKey [ , receiver ])
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect, Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.get(Symbol(1), 'p');
+});
+
+reportCompare(0, 0);