isConstructor.js (1287B)
1 // Copyright (C) 2017 André Bargull. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: > 6 Including isConstructor.js will expose one function: 7 8 isConstructor 9 10 includes: [isConstructor.js] 11 features: [generators, Reflect.construct] 12 ---*/ 13 14 assert.sameValue(typeof isConstructor, "function"); 15 16 assert.throws(Test262Error, () => isConstructor(), "no argument"); 17 assert.throws(Test262Error, () => isConstructor(undefined), "undefined"); 18 assert.throws(Test262Error, () => isConstructor(null), "null"); 19 assert.throws(Test262Error, () => isConstructor(123), "number"); 20 assert.throws(Test262Error, () => isConstructor(true), "boolean - true"); 21 assert.throws(Test262Error, () => isConstructor(false), "boolean - false"); 22 assert.throws(Test262Error, () => isConstructor("string"), "string"); 23 24 assert.throws(Test262Error, () => isConstructor({}), "Object instance"); 25 assert.throws(Test262Error, () => isConstructor([]), "Array instance"); 26 27 assert.sameValue(isConstructor(function(){}), true); 28 assert.sameValue(isConstructor(function*(){}), false); 29 assert.sameValue(isConstructor(() => {}), false); 30 31 assert.sameValue(isConstructor(Array), true); 32 assert.sameValue(isConstructor(Array.prototype.map), false); 33 34 reportCompare(0, 0);