|
1 // Map surfaces |
|
2 |
|
3 load(libdir + "iteration.js"); |
|
4 |
|
5 var desc = Object.getOwnPropertyDescriptor(this, "Map"); |
|
6 assertEq(desc.enumerable, false); |
|
7 assertEq(desc.configurable, true); |
|
8 assertEq(desc.writable, true); |
|
9 |
|
10 assertEq(typeof Map, 'function'); |
|
11 assertEq(Object.keys(Map).length, 0); |
|
12 assertEq(Map.length, 0); |
|
13 assertEq(Map.name, "Map"); |
|
14 |
|
15 assertEq(Object.getPrototypeOf(Map.prototype), Object.prototype); |
|
16 assertEq(Object.prototype.toString.call(Map.prototype), "[object Map]"); |
|
17 assertEq(Object.prototype.toString.call(new Map), "[object Map]"); |
|
18 assertEq(Object.prototype.toString.call(Map()), "[object Map]"); |
|
19 assertEq(Object.keys(Map.prototype).join(), ""); |
|
20 assertEq(Map.prototype.constructor, Map); |
|
21 |
|
22 function checkMethod(name, arity) { |
|
23 var desc = Object.getOwnPropertyDescriptor(Map.prototype, name); |
|
24 assertEq(desc.enumerable, false); |
|
25 assertEq(desc.configurable, true); |
|
26 assertEq(desc.writable, true); |
|
27 assertEq(typeof desc.value, 'function'); |
|
28 assertEq(desc.value.name, name); |
|
29 assertEq(desc.value.length, arity); |
|
30 } |
|
31 |
|
32 checkMethod("get", 1); |
|
33 checkMethod("has", 1); |
|
34 checkMethod("set", 2); |
|
35 checkMethod("delete", 1); |
|
36 checkMethod("keys", 0); |
|
37 checkMethod("values", 0); |
|
38 checkMethod("entries", 0); |
|
39 |
|
40 var desc = Object.getOwnPropertyDescriptor(Map.prototype, "size"); |
|
41 assertEq(desc.enumerable, false); |
|
42 assertEq(desc.configurable, true); |
|
43 assertEq(typeof desc.get, 'function'); |
|
44 assertEq(desc.get.length, 0); |
|
45 assertEq(desc.set, undefined); |
|
46 checkMethod("clear", 0); |
|
47 |
|
48 // Map.prototype[@@iterator] and .entries are the same function object. |
|
49 assertEq(Map.prototype[std_iterator], Map.prototype.entries); |