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

Unified Diff: test/mjsunit/harmony/block-function-sloppy.js

Issue 1234433002: [es6] Sloppy functions in block (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: We need to use 2 different unresoved proxies Created 5 years, 5 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
Index: test/mjsunit/harmony/block-function-sloppy.js
diff --git a/test/mjsunit/harmony/block-function-sloppy.js b/test/mjsunit/harmony/block-function-sloppy.js
new file mode 100644
index 0000000000000000000000000000000000000000..0b81fe08d7bae201c9f2b3ca945a3233de071633
--- /dev/null
+++ b/test/mjsunit/harmony/block-function-sloppy.js
@@ -0,0 +1,123 @@
+// Copyright 2014 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.
+
+// Flags: --harmony-sloppy --no-legacy-const
+
+
+(function TestHoistingToBlock() {
+ assertEquals(f, undefined);
+ {
+ assertEquals(1, f());
+ function f() { return 1; }
+ assertEquals(1, f());
+ }
+ assertEquals(1, f());
+})();
+
+
+(function TestOnlyOneFunction() {
+ var outer, inner;
+ {
+ function f() { return 1; }
+ inner = f;
+ }
+ outer = f;
+ assertEquals(inner, outer);
+})();
+
+
+(function TestNoInitIf() {
rossberg 2015/07/10 12:18:27 You have all these tests for the NoInit case, but
arv (Not doing code reviews) 2015/07/10 12:56:12 Doh! I will add.
+ assertEquals(f, undefined);
+ if (false) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitElse() {
+ assertEquals(f, undefined);
+ if (true) {
+ } else {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitWhile() {
+ assertEquals(f, undefined);
+ while (false) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitFor() {
+ assertEquals(f, undefined);
+ for (; false; ) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitForLet() {
+ assertEquals(f, undefined);
+ for (let x; false; ) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitForIn() {
+ assertEquals(f, undefined);
+ for (var k in {}) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+
+(function TestNoInitForInLet() {
+ assertEquals(f, undefined);
+ for (let k in {}) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitForOf() {
+ assertEquals(f, undefined);
+ for (var v of []) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoInitForOfLet() {
+ assertEquals(f, undefined);
+ for (let v of []) {
+ function f() { return 1; }
+ }
+ assertEquals(f, undefined);
+})();
+
+
+(function TestNoVarBindingInCaseOfEarlyError() {
+ let f = 1;
+ assertEquals(1, f);
+ {
+ assertEquals(2, f());
+ function f() { return 2; }
+ assertEquals(2, f());
+ }
+ assertEquals(1, f);
+
+})();

Powered by Google App Engine
This is Rietveld 408576698