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

Unified Diff: test/mjsunit/es6/block-scope-class.js

Issue 1571793002: Reland of Ship ES2015 sloppy-mode function hoisting, let, class (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/block-non-strict-errors.js ('k') | test/mjsunit/es6/classes-derived-return-type.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/block-scope-class.js
diff --git a/test/mjsunit/es6/block-scope-class.js b/test/mjsunit/es6/block-scope-class.js
new file mode 100644
index 0000000000000000000000000000000000000000..351feaa90e13b5434f101615e2b08fdaf451dd8b
--- /dev/null
+++ b/test/mjsunit/es6/block-scope-class.js
@@ -0,0 +1,59 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Test for conflicting variable bindings.
+
+// Flags: --harmony-sloppy --harmony-sloppy-function
+
+function AssertEqualsStrictAndSloppy(value, code) {
+ assertEquals(value, eval("(function() {" + code + "})()"));
+ assertEquals(value, eval("(function() { 'use strict'; " + code + "})()"));
+ assertEquals(value, eval("(function() { var x = 0; {" + code + "} })()"));
+ assertEquals(value, eval("(function() { 'use strict'; var x = 0; {"
+ + code + "} })()"));
+}
+
+function AssertThrowsStrictAndSloppy(code, error) {
+ assertThrows("(function() {" + code + "})()", error);
+ assertThrows("(function() { 'use strict'; " + code + "})()", error);
+ assertThrows("(function() { var x = 0; { " + code + "} })()", error);
+ assertThrows("(function() { 'use strict'; var x = 0; {" + code + "} })()",
+ error);
+}
+
+(function TestClassTDZ() {
+ AssertEqualsStrictAndSloppy(
+ "x", "function f() { return x; }; class x { }; return f().name;");
+ AssertEqualsStrictAndSloppy
+ ("x", "class x { }; function f() { return x; }; return f().name;");
+ AssertEqualsStrictAndSloppy(
+ "x", "class x { }; var result = f().name; " +
+ "function f() { return x; }; return result;");
+ AssertThrowsStrictAndSloppy(
+ "function f() { return x; }; f(); class x { };", ReferenceError);
+ AssertThrowsStrictAndSloppy(
+ "f(); function f() { return x; }; class x { };", ReferenceError);
+ AssertThrowsStrictAndSloppy(
+ "f(); class x { }; function f() { return x; };", ReferenceError);
+ AssertThrowsStrictAndSloppy(
+ "var x = 1; { f(); class x { }; function f() { return x; }; }",
+ ReferenceError);
+ AssertThrowsStrictAndSloppy("x = 3; class x { };", ReferenceError)
+})();
+
+(function TestClassNameConflict() {
+ AssertThrowsStrictAndSloppy("class x { }; var x;", SyntaxError);
+ AssertThrowsStrictAndSloppy("var x; class x { };", SyntaxError);
+ AssertThrowsStrictAndSloppy("class x { }; function x() { };", SyntaxError);
+ AssertThrowsStrictAndSloppy("function x() { }; class x { };", SyntaxError);
+ AssertThrowsStrictAndSloppy("class x { }; for (var x = 0; false;) { };",
+ SyntaxError);
+ AssertThrowsStrictAndSloppy("for (var x = 0; false;) { }; class x { };",
+ SyntaxError);
+})();
+
+(function TestClassMutableBinding() {
+ AssertEqualsStrictAndSloppy(
+ "x3", "class x { }; var y = x.name; x = 3; return y + x;")
+})();
« no previous file with comments | « test/mjsunit/es6/block-non-strict-errors.js ('k') | test/mjsunit/es6/classes-derived-return-type.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698