|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 function checkMethod(method) { |
|
7 try { |
|
8 new method(); |
|
9 assertEq(0, 1, "not reached " + method); |
|
10 } catch (e) { |
|
11 assertEq(e.message, "method is not a constructor"); |
|
12 } |
|
13 } |
|
14 |
|
15 function checkMethods(proto) { |
|
16 var names = Object.getOwnPropertyNames(proto); |
|
17 for (var i = 0; i < names.length; i++) { |
|
18 var name = names[i]; |
|
19 if (name == "constructor") |
|
20 continue; |
|
21 var prop = proto[name]; |
|
22 if (typeof prop === "function") |
|
23 checkMethod(prop); |
|
24 } |
|
25 } |
|
26 |
|
27 checkMethod(Function.prototype); |
|
28 checkMethods(JSON); |
|
29 checkMethods(Math); |
|
30 checkMethods(Proxy); |
|
31 |
|
32 var builtin_ctors = [ |
|
33 Object, Function, Array, String, Boolean, Number, Date, RegExp, Error, |
|
34 EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, |
|
35 ]; |
|
36 |
|
37 for (var i = 0; i < builtin_ctors.length; i++) { |
|
38 checkMethods(builtin_ctors[i]); |
|
39 checkMethods(builtin_ctors[i].prototype); |
|
40 } |
|
41 |
|
42 var builtin_funcs = [ |
|
43 eval, isFinite, isNaN, parseFloat, parseInt, |
|
44 decodeURI, decodeURIComponent, encodeURI, encodeURIComponent |
|
45 ]; |
|
46 |
|
47 for (var i = 0; i < builtin_funcs.length; i++) { |
|
48 checkMethod(builtin_funcs[i]); |
|
49 } |
|
50 |
|
51 if (typeof reportCompare == 'function') |
|
52 reportCompare(0, 0, "ok"); |