From fa1f59c8564a0d81bcb2a4de0883394428015ed5 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Thu, 24 May 2018 13:33:37 +0530 Subject: [PATCH] assert: reverse diff direction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current direction for the assert diffs is rather peculiar. While it’s not the “wrong” way to do it per-se, it’s definitely inconsistent with the ecosystem and is rather unintuitive. This PR aims to fix that by reversing the direction. Fixes: https://github.com/nodejs/node/issues/20897 --- lib/internal/assert.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/internal/assert.js b/lib/internal/assert.js index 74f7e3f7c053c4..b6dd61b657d153 100644 --- a/lib/internal/assert.js +++ b/lib/internal/assert.js @@ -57,7 +57,7 @@ function createErrDiff(actual, expected, operator) { const actualLines = inspectValue(actual); const expectedLines = inspectValue(expected); const msg = READABLE_OPERATOR[operator] + - `:\n${green}+ expected${white} ${red}- actual${white}`; + `:\n${green}- expected${white} ${red}+ actual${white}`; const skippedMsg = ` ${blue}...${white} Lines skipped`; // Remove all ending lines that match (this optimizes the output for @@ -106,7 +106,7 @@ function createErrDiff(actual, expected, operator) { printedLines++; } lastPos = i; - other += `\n${green}+${white} ${expectedLines[i]}`; + other += `\n${green}-${white} ${expectedLines[i]}`; printedLines++; // Only extra actual lines exist } else if (expectedLines.length < i + 1) { @@ -122,7 +122,7 @@ function createErrDiff(actual, expected, operator) { printedLines++; } lastPos = i; - res += `\n${red}-${white} ${actualLines[i]}`; + res += `\n${red}+${white} ${actualLines[i]}`; printedLines++; // Lines diverge } else if (actualLines[i] !== expectedLines[i]) { @@ -138,8 +138,8 @@ function createErrDiff(actual, expected, operator) { printedLines++; } lastPos = i; - res += `\n${red}-${white} ${actualLines[i]}`; - other += `\n${green}+${white} ${expectedLines[i]}`; + res += `\n${red}+${white} ${actualLines[i]}`; + other += `\n${green}-${white} ${expectedLines[i]}`; printedLines += 2; // Lines are identical } else {