1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/collections/Map-surfaces-1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +// Map surfaces 1.5 + 1.6 +load(libdir + "iteration.js"); 1.7 + 1.8 +var desc = Object.getOwnPropertyDescriptor(this, "Map"); 1.9 +assertEq(desc.enumerable, false); 1.10 +assertEq(desc.configurable, true); 1.11 +assertEq(desc.writable, true); 1.12 + 1.13 +assertEq(typeof Map, 'function'); 1.14 +assertEq(Object.keys(Map).length, 0); 1.15 +assertEq(Map.length, 0); 1.16 +assertEq(Map.name, "Map"); 1.17 + 1.18 +assertEq(Object.getPrototypeOf(Map.prototype), Object.prototype); 1.19 +assertEq(Object.prototype.toString.call(Map.prototype), "[object Map]"); 1.20 +assertEq(Object.prototype.toString.call(new Map), "[object Map]"); 1.21 +assertEq(Object.prototype.toString.call(Map()), "[object Map]"); 1.22 +assertEq(Object.keys(Map.prototype).join(), ""); 1.23 +assertEq(Map.prototype.constructor, Map); 1.24 + 1.25 +function checkMethod(name, arity) { 1.26 + var desc = Object.getOwnPropertyDescriptor(Map.prototype, name); 1.27 + assertEq(desc.enumerable, false); 1.28 + assertEq(desc.configurable, true); 1.29 + assertEq(desc.writable, true); 1.30 + assertEq(typeof desc.value, 'function'); 1.31 + assertEq(desc.value.name, name); 1.32 + assertEq(desc.value.length, arity); 1.33 +} 1.34 + 1.35 +checkMethod("get", 1); 1.36 +checkMethod("has", 1); 1.37 +checkMethod("set", 2); 1.38 +checkMethod("delete", 1); 1.39 +checkMethod("keys", 0); 1.40 +checkMethod("values", 0); 1.41 +checkMethod("entries", 0); 1.42 + 1.43 +var desc = Object.getOwnPropertyDescriptor(Map.prototype, "size"); 1.44 +assertEq(desc.enumerable, false); 1.45 +assertEq(desc.configurable, true); 1.46 +assertEq(typeof desc.get, 'function'); 1.47 +assertEq(desc.get.length, 0); 1.48 +assertEq(desc.set, undefined); 1.49 +checkMethod("clear", 0); 1.50 + 1.51 +// Map.prototype[@@iterator] and .entries are the same function object. 1.52 +assertEq(Map.prototype[std_iterator], Map.prototype.entries);