From b55a2fd53113d70900c7cd96ad8cfdcc235629c2 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Fri, 19 Apr 2019 02:55:43 +0800 Subject: fix corner case in `functions` (#3367) fixes #3366 --- test/compress/functions.js | 31 +++++++++++++++++++++++++++++++ test/sandbox.js | 6 ++++-- 2 files changed, 35 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/compress/functions.js b/test/compress/functions.js index c43c17eb..7303b91b 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2981,3 +2981,34 @@ issue_3364: { } expect_stdout: "2" } + +issue_3366: { + options = { + functions: true, + inline: true, + reduce_vars: true, + toplevel: true, + unused: true, + } + input: { + function f() { + function g() { + return function() {}; + } + var a = g(); + (function() { + this && a && console.log("PASS"); + })(); + } + f(); + } + expect: { + (function() { + function a() {} + (function() { + this && a && console.log("PASS"); + })(); + })(); + } + expect_stdout: "PASS" +} diff --git a/test/sandbox.js b/test/sandbox.js index 23fb4fc9..396a08f1 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -73,8 +73,10 @@ exports.run_code = function(code, reuse) { process.stdout.write = original_write; if (!reuse || code.indexOf(".prototype") >= 0) { context = null; - } else for (var key in context) { - delete context[key]; + } else { + vm.runInContext(Object.keys(context).map(function(name) { + return "delete " + name; + }).join("\n"), context); } } }; -- cgit v1.2.3 on>
path: root/gnu/tests.scm
AgeCommit message (Expand)Author
2021-02-19tests: Export %simple-os....Mathieu Othacehe
2020-07-25utils: Move <location> and '&error-location' to (guix diagnostics)....Ludovic Courtès
2020-03-05tests: Add <system-test> gexp compiler....Ludovic Courtès
2020-01-23tests: Fix typo in comment....Ludovic Courtès