diff -r 000000000000 -r 6474c204b198 js/src/tests/js1_8_5/regress/regress-569464.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/js/src/tests/js1_8_5/regress/regress-569464.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,36 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Dave Herman + */ + +function earlyError(src) { + var threw; + try { + eval(src); + threw = false; + } catch (expected) { + threw = true; + } + assertEq(threw, true); +} + +earlyError("'use strict'; let (x) 42;"); +earlyError("function f() { 'use strict'; let (x) 42;"); +earlyError("'use strict'; function id(x) { return x } let (a=1) a ? f : x++(42);"); +earlyError("function id(x) { return x } function f() { 'use strict'; let (a=1) a ? f : x++(42); }"); +earlyError("'use strict'; let (x=2, y=3) x=3, y=13"); +earlyError("function f() { 'use strict'; let (x=2, y=3) x=3, y=13 }"); + +x = "global"; +(let (x=2, y=3) x=3, y=13); +assertEq(x, "global"); +assertEq(y, 13); + +// https://bugzilla.mozilla.org/show_bug.cgi?id=569464#c12 +g = (let (x=7) x*x for each (x in [1,2,3])); +for (let y in g) { + assertEq(y, 49); +} + +reportCompare(0, 0, "In strict mode, let expression statements are disallowed.");