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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/collections/Set-surfaces-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +// Set methods throw when passed a this-value that isn't a Set.
     1.5 +
     1.6 +load(libdir + "asserts.js");
     1.7 +
     1.8 +function testcase(obj, fn) {
     1.9 +    assertEq(typeof fn, "function");
    1.10 +    var args = Array.slice(arguments, 2);
    1.11 +    assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError);
    1.12 +}
    1.13 +
    1.14 +var Set_size_getter = Object.getOwnPropertyDescriptor(Set.prototype, "size").get;
    1.15 +
    1.16 +function test(obj) {
    1.17 +    testcase(obj, Set.prototype.has, 12);
    1.18 +    testcase(obj, Set.prototype.add, 12);
    1.19 +    testcase(obj, Set.prototype.delete, 12);
    1.20 +    testcase(obj, Set.prototype.clear);
    1.21 +    testcase(obj, Set.prototype.keys);
    1.22 +    testcase(obj, Set.prototype.values);
    1.23 +    testcase(obj, Set.prototype.entries);
    1.24 +    testcase(obj, Set_size_getter);
    1.25 +}
    1.26 +
    1.27 +test(Set.prototype);
    1.28 +test(Object.create(new Set));
    1.29 +test(new Map());
    1.30 +test({});
    1.31 +test(null);
    1.32 +test(undefined);

mercurial