From 4ad7b1dae46fb5bf98f12859b2906381421563d4 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 10 Jun 2017 01:08:58 +0800 Subject: [PATCH] fix portability of `sandbox.run_code()` on Node.js 0.1x (#2078) --- test/compress/sandbox.js | 14 ++++++++++++++ test/sandbox.js | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/compress/sandbox.js diff --git a/test/compress/sandbox.js b/test/compress/sandbox.js new file mode 100644 index 00000000..6c2be933 --- /dev/null +++ b/test/compress/sandbox.js @@ -0,0 +1,14 @@ +console_log: { + input: { + console.log("%% %s"); + console.log("%% %s", "%s"); + } + expect: { + console.log("%% %s"); + console.log("%% %s", "%s"); + } + expect_stdout: [ + "%% %s", + "% %s", + ] +} diff --git a/test/sandbox.js b/test/sandbox.js index ca1781c6..cb1e18c9 100644 --- a/test/sandbox.js +++ b/test/sandbox.js @@ -52,7 +52,10 @@ exports.run_code = function(code) { "}();", ].join("\n"), { console: { - log: function() { + log: function(msg) { + if (arguments.length == 1 && typeof msg == "string") { + return console.log("%s", msg); + } return console.log.apply(console, [].map.call(arguments, function(arg) { return safe_log(arg, 3); })); -- 2.34.1