Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // The decompiler correctly handles for-of loops.
3 function tokens(code) {
4 var arr = [];
5 var s = code.replace(/\w+|[^\s]/g, function (tok) { arr.push(tok); return ""; });
6 assertEq(s.trim(), "", "tokens() should find all tokens in code: " + uneval(code));
7 return arr;
8 }
10 function test(code) {
11 var before = "function f() { " + code + " }";
12 var after = eval("(" + before + ")").toString();
13 assertEq(tokens(before).join(" "), tokens(after).join(" "), "decompiler failed to round-trip");
14 }
16 // statements
17 test("for (a of b) { f(a); }");
18 test("for (a of b) { f(a); g(a); }");
20 // for-of with "in" operator nearby
21 test("for (a of b in c ? c : c.items()) { f(a); }");
23 // destructuring
24 test("for ([a, b] of c) { a.m(b); }");
26 // for-let-of
27 test("for (let a of b) { f(a); }");
28 test("for (let [a, b] of c) { a.m(b); }");
30 // array comprehensions
31 test("return [a for (a of b)];");
32 test("return [[b, a] for ([a, b] of c.items())];");
34 // generator expressions
35 test("return (a for (a of b));");