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 checkMethod(method) { michael@0: try { michael@0: new method(); michael@0: assertEq(0, 1, "not reached " + method); michael@0: } catch (e) { michael@0: assertEq(e.message, "method is not a constructor"); michael@0: } michael@0: } michael@0: michael@0: function checkMethods(proto) { michael@0: var names = Object.getOwnPropertyNames(proto); michael@0: for (var i = 0; i < names.length; i++) { michael@0: var name = names[i]; michael@0: if (name == "constructor") michael@0: continue; michael@0: var prop = proto[name]; michael@0: if (typeof prop === "function") michael@0: checkMethod(prop); michael@0: } michael@0: } michael@0: michael@0: checkMethod(Function.prototype); michael@0: checkMethods(JSON); michael@0: checkMethods(Math); michael@0: checkMethods(Proxy); michael@0: michael@0: var builtin_ctors = [ michael@0: Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, michael@0: EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, michael@0: ]; michael@0: michael@0: for (var i = 0; i < builtin_ctors.length; i++) { michael@0: checkMethods(builtin_ctors[i]); michael@0: checkMethods(builtin_ctors[i].prototype); michael@0: } michael@0: michael@0: var builtin_funcs = [ michael@0: eval, isFinite, isNaN, parseFloat, parseInt, michael@0: decodeURI, decodeURIComponent, encodeURI, encodeURIComponent michael@0: ]; michael@0: michael@0: for (var i = 0; i < builtin_funcs.length; i++) { michael@0: checkMethod(builtin_funcs[i]); michael@0: } michael@0: michael@0: if (typeof reportCompare == 'function') michael@0: reportCompare(0, 0, "ok");