michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: function checkConstruct(thing, buggy) { michael@0: try { michael@0: new thing(); michael@0: assertEq(0, 1, "not reached " + thing); michael@0: } catch (e) { michael@0: if (buggy) michael@0: assertEq(String(e.message).indexOf("is not a constructor") === -1, false); michael@0: else michael@0: assertEq(String(e.message).indexOf("thing is not a constructor") === -1, false); michael@0: } michael@0: } michael@0: michael@0: var re = /aaa/ michael@0: checkConstruct(re, false); michael@0: michael@0: var boundFunctionPrototype = Function.prototype.bind(); michael@0: checkConstruct(boundFunctionPrototype, true); michael@0: michael@0: var boundBuiltin = Math.sin.bind(); michael@0: checkConstruct(boundBuiltin, true); michael@0: michael@0: /* We set the proxies construct trap to undefined, michael@0: * so the call trap is used as constructor. michael@0: */ michael@0: michael@0: var proxiedFunctionPrototype = Proxy.create({}, Function.prototype, undefined); michael@0: checkConstruct(proxiedFunctionPrototype, false); michael@0: michael@0: var proxiedBuiltin = Proxy.create({}, parseInt, undefined); michael@0: checkConstruct(proxiedBuiltin, false); michael@0: michael@0: michael@0: if (typeof reportCompare == 'function') michael@0: reportCompare(0, 0, "ok");