summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/for-of/proxy-2.js
blob: e0c7b116ca5d46bf9e0e180d36e2fd0c26cf095a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Basic for-of test with Proxy whose iterator method is a generator.

var arr = ['a', 'b', 'c', 'd'];
var proxy = new Proxy(arr, {
    get(target, property, receiver) {
        if (property === Symbol.iterator) {
            return function* () {
                for (var i = 0; i < arr.length; i++)
                    yield arr[i];
            }
        }

        return Reflect.get(target, property, receiver);
    }
});

for (var i = 0; i < 2; i++)
    assertEq([...proxy].join(","), "a,b,c,d");