summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/Array/from_primitive.js
blob: e3f68d8bc2eba5df8b782456bb542ac1a6350e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/ */

for (let primitive of [true, 3.14, "hello", Symbol()]) {
    let prototype = Object.getPrototypeOf(primitive);

    Object.defineProperty(prototype, Symbol.iterator, {
        configurable: true,
        get() {
            "use strict";
            assertEq(this, primitive);
            return () => [this][Symbol.iterator]();
        },
    });
    assertEq(Array.from(primitive)[0], primitive);

    delete prototype[Symbol.iterator];
}

if (typeof reportCompare === 'function')
    reportCompare(0, 0);