js/src/jit-test/tests/collections/Set-surfaces-1.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial