Chromium Code Reviews| 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); |
| + |
| +})(); |