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

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: 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: --no-legacy-const --harmony-sloppy
adamk 2015/07/25 01:29:38 What does legacy const have to do with it? I see n
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; {" + code + " } })()"));
adamk 2015/07/25 01:29:38 Please wrap to 80 chars here and elsewhere in this
14 }
15
16 function AssertThrowsStrictAndSloppy(code, error) {
17 assertThrows("(function() {" + code + "})()", error);
18 assertThrows("(function() { 'use strict'; " + code + "})()", error);
19 assertThrows("(function() { var x = 0; { " + code + "} })()", error);
20 assertThrows("(function() { 'use strict'; var x = 0; {" + code + "} })()", err or);
21 }
22
23 (function TestClassTDZ() {
24 AssertEqualsStrictAndSloppy("x", "function f() { return x; }; class x { }; ret urn f().name;");
25 AssertEqualsStrictAndSloppy("x", "class x { }; function f() { return x; }; ret urn f().name;");
26 AssertEqualsStrictAndSloppy("x", "class x { }; var result = f().name; function f() { return x; }; return result;");
27 AssertThrowsStrictAndSloppy("function f() { return x; }; f(); class x { };", R eferenceError);
28 AssertThrowsStrictAndSloppy("f(); function f() { return x; }; class x { };", R eferenceError);
29 AssertThrowsStrictAndSloppy("f(); class x { }; function f() { return x; };", R eferenceError);
30 AssertThrowsStrictAndSloppy("var x = 1; { f(); class x { }; function f() { ret urn x; }; }", ReferenceError);
31 AssertThrowsStrictAndSloppy("x = 3; class x { };", ReferenceError)
32 })();
33
34 (function TestClassNameConflict() {
35 AssertThrowsStrictAndSloppy("class x { }; var x;", SyntaxError);
36 AssertThrowsStrictAndSloppy("var x; class x { };", SyntaxError);
37 AssertThrowsStrictAndSloppy("class x { }; function x() { };", SyntaxError);
38 AssertThrowsStrictAndSloppy("function x() { }; class x { };", SyntaxError);
39 AssertThrowsStrictAndSloppy("class x { }; for (var x = 0; false;) { };", Synta xError);
40 AssertThrowsStrictAndSloppy("for (var x = 0; false;) { }; class x { };", Synta xError);
41 })();
42
43 (function TestClassMutableBinding() {
44 AssertEqualsStrictAndSloppy("x3", "class x { }; var y = x.name; x = 3; return y + x;")
45 })();
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