js/src/jit-test/tests/for-of/array-iterator-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 // Superficial tests for iterators created by Array.prototype.iterator
     3 load(libdir + "iteration.js");
     5 var proto = Object.getPrototypeOf([][std_iterator]());
     6 assertEq(Object.getPrototypeOf(proto), Iterator.prototype);
     7 proto = Object.getPrototypeOf([].keys());
     8 assertEq(Object.getPrototypeOf(proto), Iterator.prototype);
     9 proto = Object.getPrototypeOf([].entries());
    10 assertEq(Object.getPrototypeOf(proto), Iterator.prototype);
    12 function check(it) {
    13     assertEq(typeof it, 'object');
    14     assertEq(Object.getPrototypeOf(it), proto);
    15     assertEq(Object.getOwnPropertyNames(it).length, 0);
    16     assertEq(it[std_iterator](), it);
    18     // for-in enumerates the iterator's properties.
    19     it.x = 0;
    20     var s = '';
    21     for (var p in it)
    22         s += p + '.';
    23     assertEq(s, 'x.');
    24 }
    26 check([][std_iterator]());
    27 check(Array.prototype[std_iterator].call({}));
    28 check([].keys());
    29 check(Array.prototype.keys.call({}));
    30 check([].entries());
    31 check(Array.prototype.entries.call({}));

mercurial