js/src/jit-test/tests/for-of/semantics-11.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 // for-of on a proxy causes a predictable sequence of trap calls.
michael@0 2
michael@0 3 load(libdir + "iteration.js");
michael@0 4
michael@0 5 var s = '';
michael@0 6
michael@0 7 var i = 0;
michael@0 8 var next_fn = Proxy.createFunction({}, function () {
michael@0 9 s += "n";
michael@0 10 if (i == 3)
michael@0 11 return { value: undefined, done: true };
michael@0 12 return { value: i++, done: false };
michael@0 13 });
michael@0 14
michael@0 15 var it = Proxy.create({
michael@0 16 get: function (receiver, name) {
michael@0 17 if (name == 'toSource') {
michael@0 18 s += '?';
michael@0 19 return function () 'it';
michael@0 20 }
michael@0 21 assertEq(name, "next");
michael@0 22 s += "N";
michael@0 23 return next_fn;
michael@0 24 }
michael@0 25 });
michael@0 26
michael@0 27 var iterator_fn = Proxy.createFunction({}, function () {
michael@0 28 s += 'i';
michael@0 29 return it;
michael@0 30 });
michael@0 31
michael@0 32 var obj = Proxy.create({
michael@0 33 get: function (receiver, name) {
michael@0 34 assertEq(name, std_iterator);
michael@0 35 s += "I";
michael@0 36 return iterator_fn;
michael@0 37 }
michael@0 38 });
michael@0 39
michael@0 40 for (var v of obj)
michael@0 41 s += v;
michael@0 42
michael@0 43 assertEq(s, 'IiNn0Nn1Nn2Nn');

mercurial