blob: db7f558905f6cc14a9c6cd876a047b4a55198f99 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --no-harmony-sloppy-let --no-harmony-sloppy-function
6// Flags: --no-harmony-sloppy
7
8function CheckError(source) {
9 var exception = null;
10 try {
11 eval(source);
12 } catch (e) {
13 exception = e;
14 }
15 assertNotNull(exception);
16 assertEquals(
17 "Block-scoped declarations (let, const, function, class) not yet supported outside strict mode",
18 exception.message);
19}
20
21
22function CheckOk(source) {
23 eval(source);
24}
25
26CheckError("let x = 1;");
27CheckError("{ let x = 1; }");
28CheckError("function f() { let x = 1; }");
29CheckError("for (let x = 1; x < 1; x++) {}");
30CheckError("for (let x of []) {}");
31CheckError("for (let x in []) {}");
32CheckError("class C {}");
33CheckError("class C extends Array {}");
34CheckError("(class {});");
35CheckError("(class extends Array {});");
36CheckError("(class C {});");
37CheckError("(class C exends Array {});");
38
39CheckOk("let = 1;");
40CheckOk("{ let = 1; }");
41CheckOk("function f() { let = 1; }");
42CheckOk("for (let = 1; let < 1; let++) {}");