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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Map methods throw when passed a this-value that isn't a Map.
     3 load(libdir + "asserts.js");
     5 function testcase(obj, fn) {
     6     assertEq(typeof fn, "function");
     7     var args = Array.slice(arguments, 2);
     8     assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError);
     9 }
    11 var Map_size_getter = Object.getOwnPropertyDescriptor(Map.prototype, "size").get;
    13 function test(obj) {
    14     testcase(obj, Map.prototype.get, "x");
    15     testcase(obj, Map.prototype.has, "x");
    16     testcase(obj, Map.prototype.set, "x", 1);
    17     testcase(obj, Map.prototype.delete, "x");
    18     testcase(obj, Map.prototype.clear);
    19     testcase(obj, Map.prototype.keys);
    20     testcase(obj, Map.prototype.values);
    21     testcase(obj, Map.prototype.entries);
    22     testcase(obj, Map_size_getter);
    23 }
    25 test(Map.prototype);
    26 test(Object.create(new Map));
    27 test(new Set());
    28 test({});
    29 test(null);
    30 test(undefined);

mercurial