mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:35:26 +00:00

Pick up latest commit from the 5.4-lkgr branch. deps: edit V8 gitignore to allow trace event copy deps: update V8 trace event to 315bf1e2d45be7d53346c31cfcc37424a32c30c8 deps: edit V8 gitignore to allow gtest_prod.h copy deps: update V8 gtest to 6f8a66431cb592dad629028a50b3dd418a408c87 PR-URL: https://github.com/nodejs/node/pull/8317 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
58 lines
2.5 KiB
JavaScript
58 lines
2.5 KiB
JavaScript
// 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.
|
|
|
|
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;")
|
|
})();
|