summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Reflect/has
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Reflect/has')
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/has.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/length.js20
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/name.js25
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-property-key.js27
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-result.js26
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/return-boolean.js42
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/symbol-property.js36
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/target-is-not-object-throws.js31
-rw-r--r--js/src/tests/test262/built-ins/Reflect/has/target-is-symbol-throws.js19
12 files changed, 301 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Reflect/has/browser.js b/js/src/tests/test262/built-ins/Reflect/has/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/browser.js
diff --git a/js/src/tests/test262/built-ins/Reflect/has/has.js b/js/src/tests/test262/built-ins/Reflect/has/has.js
new file mode 100644
index 0000000000..d0de62ffec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/has.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.9
+description: >
+ Reflect.has is configurable, writable and not enumerable.
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+verifyNotEnumerable(Reflect, 'has');
+verifyWritable(Reflect, 'has');
+verifyConfigurable(Reflect, 'has');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/length.js b/js/src/tests/test262/built-ins/Reflect/has/length.js
new file mode 100644
index 0000000000..a5a0fc4a0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.9
+description: >
+ Reflect.has.length value and property descriptor
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.has.length, 2,
+ 'The value of `Reflect.has.length` is `2`'
+);
+
+verifyNotEnumerable(Reflect.has, 'length');
+verifyNotWritable(Reflect.has, 'length');
+verifyConfigurable(Reflect.has, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/name.js b/js/src/tests/test262/built-ins/Reflect/has/name.js
new file mode 100644
index 0000000000..62e68d8983
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.9
+description: >
+ Reflect.has.name value and property descriptor
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [Reflect]
+---*/
+
+assert.sameValue(
+ Reflect.has.name, 'has',
+ 'The value of `Reflect.has.name` is `"has"`'
+);
+
+verifyNotEnumerable(Reflect.has, 'name');
+verifyNotWritable(Reflect.has, 'name');
+verifyConfigurable(Reflect.has, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js b/js/src/tests/test262/built-ins/Reflect/has/not-a-constructor.js
new file mode 100644
index 0000000000..714c8ef861
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.has 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.has), false, 'isConstructor(Reflect.has) must return false');
+
+assert.throws(TypeError, () => {
+ new Reflect.has();
+}, '`new Reflect.has()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-property-key.js b/js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-property-key.js
new file mode 100644
index 0000000000..70d1f66c89
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.9
+description: >
+ Return abrupt from ToPropertyKey(propertyKey)
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ ...
+ 2. Let key be ToPropertyKey(propertyKey).
+ 3. ReturnIfAbrupt(key).
+ ...
+features: [Reflect]
+---*/
+
+var p = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ Reflect.has({}, p);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-result.js b/js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-result.js
new file mode 100644
index 0000000000..600b2072f8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/return-abrupt-from-result.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.9
+description: >
+ Return abrupt result.
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ ...
+ 4. Return target.[[HasProperty]](key).
+features: [Proxy, Reflect]
+---*/
+
+var o = {};
+var p = new Proxy(o, {
+ has: function() {
+ throw new Test262Error();
+ }
+});
+
+assert.throws(Test262Error, function() {
+ Reflect.has(p, 'p1');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/return-boolean.js b/js/src/tests/test262/built-ins/Reflect/has/return-boolean.js
new file mode 100644
index 0000000000..b051ae2b8f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/return-boolean.js
@@ -0,0 +1,42 @@
+// 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.9
+description: >
+ Return boolean value.
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ ...
+ 4. Return target.[[HasProperty]](key).
+
+
+ 9.1.7.1 OrdinaryHasProperty (O, P)
+
+ ...
+ 2. Let hasOwn be OrdinaryGetOwnProperty(O, P).
+ 3. If hasOwn is not undefined, return true.
+ 4. Let parent be O.[[GetPrototypeOf]]().
+ 5. ReturnIfAbrupt(parent).
+ 6. If parent is not null, then
+ a. Return parent.[[HasProperty]](P).
+ 7. Return false.
+features: [Reflect]
+---*/
+
+var o1 = {
+ p: 42
+};
+
+assert.sameValue(Reflect.has(o1, 'p'), true, 'true from own property');
+assert.sameValue(
+ Reflect.has(o1, 'z'), false,
+ 'false when property is not present'
+);
+
+var o2 = Object.create({
+ p: 42
+});
+assert.sameValue(Reflect.has(o2, 'p'), true, 'true from a prototype property');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/shell.js b/js/src/tests/test262/built-ins/Reflect/has/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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/has/symbol-property.js b/js/src/tests/test262/built-ins/Reflect/has/symbol-property.js
new file mode 100644
index 0000000000..49754ec000
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/symbol-property.js
@@ -0,0 +1,36 @@
+// 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.9
+description: >
+ Return boolean value from a projectKey as a Symbol
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ ...
+ 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 s1 = Symbol('1');
+o[s1] = 42;
+
+var s2 = Symbol('1');
+
+
+assert.sameValue(Reflect.has(o, s1), true, 'true from own property');
+assert.sameValue(
+ Reflect.has(o, s2), false,
+ 'false when property is not present'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/target-is-not-object-throws.js b/js/src/tests/test262/built-ins/Reflect/has/target-is-not-object-throws.js
new file mode 100644
index 0000000000..e0c87d8708
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.9
+description: >
+ Throws a TypeError if target is not an Object.
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.has(1, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.has(null, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.has(undefined, 'p');
+});
+
+assert.throws(TypeError, function() {
+ Reflect.has('', 'p');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Reflect/has/target-is-symbol-throws.js b/js/src/tests/test262/built-ins/Reflect/has/target-is-symbol-throws.js
new file mode 100644
index 0000000000..8529334f18
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Reflect/has/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.9
+description: >
+ Throws a TypeError if target is a Symbol
+info: |
+ 26.1.9 Reflect.has ( target, propertyKey )
+
+ 1. If Type(target) is not Object, throw a TypeError exception.
+ ...
+features: [Reflect, Symbol]
+---*/
+
+assert.throws(TypeError, function() {
+ Reflect.has(Symbol(1), 'p');
+});
+
+reportCompare(0, 0);