1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_6/Comprehensions/scope.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,18 @@ 1.4 +// The identifier of a ComprehensionFor is only bound within its tail. 1.5 + 1.6 +function t() { 1.7 + var x = [0, 1, 2]; 1.8 + return [for (x of x) x*2] 1.9 +} 1.10 +assertDeepEq(t(), [0, 2, 4]); 1.11 + 1.12 +// Each iteration should create a fresh binding. Unfortunately this is 1.13 +// not currently the case, but bug 449811 will fix this. 1.14 +function t2() { 1.15 + var x = [0, 1, 2]; 1.16 + return [for (x of x) ()=>x] 1.17 +} 1.18 +// FIXME: Should be [0, 1, 2]. 1.19 +assertDeepEq([for (x of t2()) x()], [2, 2, 2]); 1.20 + 1.21 +reportCompare(null, null, "test");