Upgrade V8 to 5.1.281.57 DO NOT MERGE
FPIIM-449
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
(cherry picked from commit 3b9bc31999c9787eb726ecdbfd5796bfdec32a18)
diff --git a/test/mjsunit/harmony/sloppy-restrictive-block-function.js b/test/mjsunit/harmony/sloppy-restrictive-block-function.js
new file mode 100644
index 0000000..07ce64b
--- /dev/null
+++ b/test/mjsunit/harmony/sloppy-restrictive-block-function.js
@@ -0,0 +1,52 @@
+// Copyright 2016 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-restrictive-declarations
+
+// ES#sec-functiondeclarations-in-ifstatement-statement-clauses
+// Annex B 3.4 FunctionDeclarations in IfStatement Statement Clauses
+// In sloppy mode, function declarations in if statements act like
+// they have a block around them. Prohibited in strict mode.
+(function() {
+ if (false) function f() { };
+ assertEquals(undefined, f);
+})();
+
+(function() {
+ assertEquals(undefined, f);
+ if (true) function f() { };
+ assertEquals('function', typeof f);
+})();
+
+(function() {
+ assertEquals(undefined, f);
+ if (true) {} else function f() { };
+ assertEquals(undefined, f);
+})();
+
+(function() {
+ assertEquals(undefined, f);
+ if (false) {} else function f() { };
+ assertEquals('function', typeof f);
+})();
+
+// Labeled function declarations undergo the same hoisting/FiB semantics as if
+// they were unalbeled.
+(function() {
+ function bar() {
+ return f;
+ x: function f() {}
+ }
+ assertEquals('function', typeof bar());
+})();
+
+(function() {
+ function bar() {
+ return f;
+ {
+ x: function f() {}
+ }
+ }
+ assertEquals(undefined, bar());
+})();