From 1b08e622aa999294b6e0191853eab05f28af3315 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 26 Mar 2019 09:15:10 +0100 Subject: [PATCH] util: improve proxy inspection This makes sure the brace is actually handled as any other brace. It was handled differently so far than any other brace and that had an impact on how the output would be formatted. PR-URL: https://github.com/nodejs/node/pull/26919 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- lib/internal/util/inspect.js | 3 +-- test/parallel/test-util-inspect-proxy.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index d52e976c0bb449..f26b35b2874846 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -404,8 +404,7 @@ function formatProxy(ctx, proxy, recurseTimes) { formatValue(ctx, proxy[1], recurseTimes) ]; ctx.indentationLvl -= 2; - const str = reduceToSingleString(ctx, res, '', ['[', ']']); - return `Proxy ${str}`; + return reduceToSingleString(ctx, res, '', ['Proxy [', ']']); } function findTypedConstructor(value) { diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js index adc0810722d553..0d6ebc6271af40 100644 --- a/test/parallel/test-util-inspect-proxy.js +++ b/test/parallel/test-util-inspect-proxy.js @@ -50,12 +50,15 @@ const expected1 = 'Proxy [ {}, {} ]'; const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]'; const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]'; const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]'; -const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' + - ' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' + - ', Proxy [ Proxy [Array], {} ] ] ]'; -const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' + - ' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' + - ' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' + +const expected5 = 'Proxy [\n ' + + 'Proxy [ Proxy [ Proxy [Array], {} ], Proxy [ {}, {} ] ],\n' + + ' Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [Array], {} ] ] ]'; +const expected6 = 'Proxy [\n' + + ' Proxy [\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ],\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ] ],\n' + + ' Proxy [\n' + + ' Proxy [ Proxy [Array], Proxy [Array] ],\n' + ' Proxy [ Proxy [Array], Proxy [Array] ] ] ]'; assert.strictEqual( util.inspect(proxy1, { showProxy: true, depth: null }),