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

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

Issue 2112163002: Block-scoped functions in evals are now only conditionally hoisted out. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: more tests Created 4 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
« no previous file with comments | « test/mjsunit/es6/block-eval-var-over-let.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/block-sloppy-function.js
diff --git a/test/mjsunit/es6/block-sloppy-function.js b/test/mjsunit/es6/block-sloppy-function.js
index 9a854ac272714ed307d2cd264f935508b639080f..8cb9a4deda80f4d822818caade60b6cbf1dbe7a4 100644
--- a/test/mjsunit/es6/block-sloppy-function.js
+++ b/test/mjsunit/es6/block-sloppy-function.js
@@ -461,7 +461,7 @@
try {
throw 0;
- } catch(f) {
+ } catch (f) {
{
assertEquals(4, f());
@@ -471,6 +471,8 @@
assertEquals(4, f());
}
+
+ assertEquals(0, f);
}
assertEquals(4, f());
@@ -479,7 +481,7 @@
(function noHoistingThroughComplexCatch() {
try {
throw 0;
- } catch({f}) {
+ } catch ({f}) {
{
assertEquals(4, f());
@@ -494,6 +496,26 @@
assertThrows(()=>f, ReferenceError);
})();
+(function hoistingThroughWith() {
+ with ({f: 0}) {
+ assertEquals(0, f);
+
+ {
+ assertEquals(4, f());
+
+ function f() {
+ return 4;
+ }
+
+ assertEquals(4, f());
+ }
+
+ assertEquals(0, f);
+ }
+
+ assertEquals(4, f());
+})();
+
// Test that hoisting from blocks does happen in global scope
function globalHoisted() { return 0; }
{
@@ -572,30 +594,63 @@ eval(`
`);
}();
+// This test is incorrect BUG(v8:5168). The commented assertions are correct.
+(function evalHoistingThroughSimpleCatch() {
+ try {
+ throw 0;
+ } catch (f) {
+ eval(`{ function f() {
+ return 4;
+ } }`);
+
+ // assertEquals(0, f);
+ assertEquals(4, f());
+ }
+
+ // assertEquals(4, f());
+ assertEquals(undefined, f);
+})();
+
+// This test is incorrect BUG(v8:5168). The commented assertions are correct.
+(function evalHoistingThroughWith() {
+ with ({f: 0}) {
+ eval(`{ function f() {
+ return 4;
+ } }`);
+
+ // assertEquals(0, f);
+ assertEquals(4, f());
+ }
+
+ // assertEquals(4, f());
+ assertEquals(undefined, f);
+})();
+
let dontHoistGlobal;
{ function dontHoistGlobal() {} }
assertEquals(undefined, dontHoistGlobal);
let dontHoistEval;
-// BUG(v8:) This shouldn't hoist and shouldn't throw
var throws = false;
try {
eval("{ function dontHoistEval() {} }");
} catch (e) {
throws = true;
}
-assertTrue(throws);
+assertFalse(throws);
// When the global object is frozen, silently don't hoist
// Currently this actually throws BUG(v8:4452)
Object.freeze(this);
-throws = false;
-try {
- eval('{ function hoistWhenFrozen() {} }');
-} catch (e) {
- throws = true;
+{
+ let throws = false;
+ try {
+ eval('{ function hoistWhenFrozen() {} }');
+ } catch (e) {
+ throws = true;
+ }
+ assertFalse(this.hasOwnProperty("hoistWhenFrozen"));
+ assertThrows(() => hoistWhenFrozen, ReferenceError);
+ // Should be assertFalse BUG(v8:4452)
+ assertTrue(throws);
}
-assertFalse(this.hasOwnProperty("hoistWhenFrozen"));
-assertThrows(() => hoistWhenFrozen, ReferenceError);
-// Should be assertFalse BUG(v8:4452)
-assertTrue(throws);
« no previous file with comments | « test/mjsunit/es6/block-eval-var-over-let.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698