Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Side by Side Diff: test/mjsunit/harmony/block-scope-class.js

Issue 1254003004: Class block scoping tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix style and flag Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 // Test for conflicting variable bindings.
6
7 // Flags: --harmony-sloppy
8
9 function AssertEqualsStrictAndSloppy(value, code) {
10 assertEquals(value, eval("(function() {" + code + "})()"));
11 assertEquals(value, eval("(function() { 'use strict'; " + code + "})()"));
12 assertEquals(value, eval("(function() { var x = 0; {" + code + "} })()"));
13 assertEquals(value, eval("(function() { 'use strict'; var x = 0; {"
14 + code + "} })()"));
15 }
16
17 function AssertThrowsStrictAndSloppy(code, error) {
18 assertThrows("(function() {" + code + "})()", error);
19 assertThrows("(function() { 'use strict'; " + code + "})()", error);
20 assertThrows("(function() { var x = 0; { " + code + "} })()", error);
21 assertThrows("(function() { 'use strict'; var x = 0; {" + code + "} })()",
22 error);
23 }
24
25 (function TestClassTDZ() {
26 AssertEqualsStrictAndSloppy(
27 "x", "function f() { return x; }; class x { }; return f().name;");
28 AssertEqualsStrictAndSloppy
29 ("x", "class x { }; function f() { return x; }; return f().name;");
30 AssertEqualsStrictAndSloppy(
31 "x", "class x { }; var result = f().name; " +
32 "function f() { return x; }; return result;");
33 AssertThrowsStrictAndSloppy(
34 "function f() { return x; }; f(); class x { };", ReferenceError);
35 AssertThrowsStrictAndSloppy(
36 "f(); function f() { return x; }; class x { };", ReferenceError);
37 AssertThrowsStrictAndSloppy(
38 "f(); class x { }; function f() { return x; };", ReferenceError);
39 AssertThrowsStrictAndSloppy(
40 "var x = 1; { f(); class x { }; function f() { return x; }; }",
41 ReferenceError);
42 AssertThrowsStrictAndSloppy("x = 3; class x { };", ReferenceError)
43 })();
44
45 (function TestClassNameConflict() {
46 AssertThrowsStrictAndSloppy("class x { }; var x;", SyntaxError);
47 AssertThrowsStrictAndSloppy("var x; class x { };", SyntaxError);
48 AssertThrowsStrictAndSloppy("class x { }; function x() { };", SyntaxError);
49 AssertThrowsStrictAndSloppy("function x() { }; class x { };", SyntaxError);
50 AssertThrowsStrictAndSloppy("class x { }; for (var x = 0; false;) { };",
51 SyntaxError);
52 AssertThrowsStrictAndSloppy("for (var x = 0; false;) { }; class x { };",
53 SyntaxError);
54 })();
55
56 (function TestClassMutableBinding() {
57 AssertEqualsStrictAndSloppy(
58 "x3", "class x { }; var y = x.name; x = 3; return y + x;")
59 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698