diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-29 05:21:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 13:21:19 +0800 |
commit | 35435d4bd302e33011e91260f2c4b94f429b7a52 (patch) | |
tree | aaad576bb53f5ebefeda93a2119e9a944b0b6da6 | |
parent | d0bb1476397d2cf6f240267aa003fe6edc445683 (diff) | |
download | tracifyjs-35435d4bd302e33011e91260f2c4b94f429b7a52.tar.gz tracifyjs-35435d4bd302e33011e91260f2c4b94f429b7a52.zip |
suppress false positives due to nested objects (#4597)
-rw-r--r-- | test/compress/sandbox.js | 25 | ||||
-rw-r--r-- | test/sandbox.js | 4 |
2 files changed, 27 insertions, 2 deletions
diff --git a/test/compress/sandbox.js b/test/compress/sandbox.js index 338afd11..9cf76725 100644 --- a/test/compress/sandbox.js +++ b/test/compress/sandbox.js @@ -98,6 +98,31 @@ log_global: { expect_stdout: "[object global]" } +log_nested: { + options = { + unused: true, + } + input: { + var o = { p: 42 }; + for (var i = 0; i < 10; i++) + o = { + p: o, + q: function foo() {}, + }; + console.log(o); + } + expect: { + var o = { p: 42 }; + for (var i = 0; i < 10; i++) + o = { + p: o, + q: function() {}, + }; + console.log(o); + } + expect_stdout: true +} + timers: { options = { reduce_vars: true, diff --git a/test/sandbox.js b/test/sandbox.js index 8f5d04da..d8d2da0d 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -126,7 +126,7 @@ function setup(global, builtins, setup_log, setup_tty) { if (arguments.length == 1 && typeof msg == "string") return log("%s", msg); return log.apply(null, [].map.call(arguments, function(arg) { return safe_log(arg, { - level: 3, + level: 5, original: [], replaced: [], }); @@ -189,7 +189,7 @@ function setup(global, builtins, setup_log, setup_tty) { arg.constructor.toString(); var index = cache.original.indexOf(arg); if (index >= 0) return cache.replaced[index]; - if (--cache.level < 0) break; + if (--cache.level < 0) return "[object Object]"; var value = {}; cache.original.push(arg); cache.replaced.push(value); |