michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: Dave Herman michael@0: */ michael@0: michael@0: function earlyError(src) { michael@0: var threw; michael@0: try { michael@0: eval(src); michael@0: threw = false; michael@0: } catch (expected) { michael@0: threw = true; michael@0: } michael@0: assertEq(threw, true); michael@0: } michael@0: michael@0: earlyError("'use strict'; let (x) 42;"); michael@0: earlyError("function f() { 'use strict'; let (x) 42;"); michael@0: earlyError("'use strict'; function id(x) { return x } let (a=1) a ? f : x++(42);"); michael@0: earlyError("function id(x) { return x } function f() { 'use strict'; let (a=1) a ? f : x++(42); }"); michael@0: earlyError("'use strict'; let (x=2, y=3) x=3, y=13"); michael@0: earlyError("function f() { 'use strict'; let (x=2, y=3) x=3, y=13 }"); michael@0: michael@0: x = "global"; michael@0: (let (x=2, y=3) x=3, y=13); michael@0: assertEq(x, "global"); michael@0: assertEq(y, 13); michael@0: michael@0: // https://bugzilla.mozilla.org/show_bug.cgi?id=569464#c12 michael@0: g = (let (x=7) x*x for each (x in [1,2,3])); michael@0: for (let y in g) { michael@0: assertEq(y, 49); michael@0: } michael@0: michael@0: reportCompare(0, 0, "In strict mode, let expression statements are disallowed.");