summaryrefslogtreecommitdiff
path: root/harness
diff options
context:
space:
mode:
Diffstat (limited to 'harness')
-rw-r--r--harness/features.yml1
-rw-r--r--harness/isConstructor.js16
2 files changed, 17 insertions, 0 deletions
diff --git a/harness/features.yml b/harness/features.yml
index 177bec32b..d08adaf64 100644
--- a/harness/features.yml
+++ b/harness/features.yml
@@ -1,3 +1,4 @@
typeCoercion.js: [Symbol.toPrimitive, BigInt]
testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, arrow-function, let, for-of]
testTypedArray.js: [TypedArray]
+isConstructor.js: [Reflect.construct]
diff --git a/harness/isConstructor.js b/harness/isConstructor.js
new file mode 100644
index 000000000..bf7433219
--- /dev/null
+++ b/harness/isConstructor.js
@@ -0,0 +1,16 @@
+// 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.
+---*/
+
+function isConstructor(f) {
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}