| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8217441 commit 8157a50
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,7 +122,7 @@ function createErrDiff(actual, expected, operator) { | |||
| 122 | 122 | let a = actualLines[actualLines.length - 1]; | |
| 123 | 123 | let b = expectedLines[expectedLines.length - 1]; | |
| 124 | 124 | while (a === b) { | |
| 125 | - if (i++ < 2) { | ||
| 125 | + if (i++ < 3) { | ||
| 126 | 126 | end = `\n ${a}${end}`; | |
| 127 | 127 | } else { | |
| 128 | 128 | other = a; | |
@@ -154,7 +154,9 @@ function createErrDiff(actual, expected, operator) { | |||
| 154 | 154 | return `${kReadableOperator.notIdentical}\n\n${actualLines.join('\n')}\n`; | |
| 155 | 155 | } | |
| 156 | 156 | ||
| 157 | - if (i > 3) { | ||
| 157 | + // There were at least five identical lines at the end. Mark a couple of | ||
| 158 | + // skipped. | ||
| 159 | + if (i >= 5) { | ||
| 158 | 160 | end = `\n${blue}...${white}${end}`; | |
| 159 | 161 | skipped = true; | |
| 160 | 162 | } | |
@@ -169,46 +171,46 @@ function createErrDiff(actual, expected, operator) { | |||
| 169 | 171 | `\n${green}+ actual${white} ${red}- expected${white}`; | |
| 170 | 172 | const skippedMsg = ` ${blue}...${white} Lines skipped`; | |
| 171 | 173 | ||
| 174 | + let lines = actualLines; | ||
| 175 | + let plusMinus = `${green}+${white}`; | ||
| 176 | + let maxLength = expectedLines.length; | ||
| 177 | + if (actualLines.length < maxLines) { | ||
| 178 | + lines = expectedLines; | ||
| 179 | + plusMinus = `${red}-${white}`; | ||
| 180 | + maxLength = actualLines.length; | ||
| 181 | + } | ||
| 182 | + | ||
| 172 | 183 | for (i = 0; i < maxLines; i++) { | |
| 173 | - if (actualLines.length < i + 1) { | ||
| 174 | - // If more than one former line is identical, print that. Collapse those | ||
| 175 | - // in case more than three lines before were identical. | ||
| 176 | - if (identical > 1) { | ||
| 184 | + if (maxLength < i + 1) { | ||
| 185 | + // If more than two former lines are identical, print them. Collapse them | ||
| 186 | + // in case more than five lines were identical. | ||
| 187 | + if (identical > 2) { | ||
| 177 | 188 | if (identical > 3) { | |
| 178 | - res += `\n${blue}...${white}`; | ||
| 179 | - skipped = true; | ||
| 180 | - } else if (identical > 2) { | ||
| 181 | - res += `\n ${expectedLines[i - 2]}`; | ||
| 189 | + if (identical > 4) { | ||
| 190 | + if (identical === 5) { | ||
| 191 | + res += `\n ${lines[i - 3]}`; | ||
| 192 | + printedLines++; | ||
| 193 | + } else { | ||
| 194 | + res += `\n${blue}...${white}`; | ||
| 195 | + skipped = true; | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + res += `\n ${lines[i - 2]}`; | ||
| 182 | 199 | printedLines++; | |
| 183 | 200 | } | |
| 184 | - res += `\n ${expectedLines[i - 1]}`; | ||
| 201 | + res += `\n ${lines[i - 1]}`; | ||
| 185 | 202 | printedLines++; | |
| 186 | 203 | } | |
| 187 | 204 | // No identical lines before. | |
| 188 | 205 | identical = 0; | |
| 189 | 206 | // Add the expected line to the cache. | |
| 190 | - other += `\n${red}-${white} ${expectedLines[i]}`; | ||
| 191 | - printedLines++; | ||
| 192 | - // Only extra actual lines exist | ||
| 193 | - } else if (expectedLines.length < i + 1) { | ||
| 194 | - // If more than one former line is identical, print that. Collapse those | ||
| 195 | - // in case more than three lines before were identical. | ||
| 196 | - if (identical > 1) { | ||
| 197 | - if (identical > 3) { | ||
| 198 | - res += `\n${blue}...${white}`; | ||
| 199 | - skipped = true; | ||
| 200 | - } else if (identical > 2) { | ||
| 201 | - res += `\n ${actualLines[i - 2]}`; | ||
| 202 | - printedLines++; | ||
| 203 | - } | ||
| 204 | - res += `\n ${actualLines[i - 1]}`; | ||
| 205 | - printedLines++; | ||
| 207 | + if (lines === actualLines) { | ||
| 208 | + res += `\n${plusMinus} ${lines[i]}`; | ||
| 209 | + } else { | ||
| 210 | + other += `\n${plusMinus} ${lines[i]}`; | ||
| 206 | 211 | } | |
| 207 | - // No identical lines before. | ||
| 208 | - identical = 0; | ||
| 209 | - // Add the actual line to the result. | ||
| 210 | - res += `\n${green}+${white} ${actualLines[i]}`; | ||
| 211 | 212 | printedLines++; | |
| 213 | + // Only extra actual lines exist | ||
| 212 | 214 | // Lines diverge | |
| 213 | 215 | } else { | |
| 214 | 216 | const expectedLine = expectedLines[i]; | |
@@ -235,13 +237,19 @@ function createErrDiff(actual, expected, operator) { | |||
| 235 | 237 | actualLine += ','; | |
| 236 | 238 | } | |
| 237 | 239 | if (divergingLines) { | |
| 238 | - // If more than one former line is identical, print that. Collapse those | ||
| 239 | - // in case more than three lines before were identical. | ||
| 240 | - if (identical > 1) { | ||
| 240 | + // If more than two former lines are identical, print them. Collapse | ||
| 241 | + // them in case more than five lines were identical. | ||
| 242 | + if (identical > 2) { | ||
| 241 | 243 | if (identical > 3) { | |
| 242 | - res += `\n${blue}...${white}`; | ||
| 243 | - skipped = true; | ||
| 244 | - } else if (identical > 2) { | ||
| 244 | + if (identical > 4) { | ||
| 245 | + if (identical === 5) { | ||
| 246 | + res += `\n ${actualLines[i - 3]}`; | ||
| 247 | + printedLines++; | ||
| 248 | + } else { | ||
| 249 | + res += `\n${blue}...${white}`; | ||
| 250 | + skipped = true; | ||
| 251 | + } | ||
| 252 | + } | ||
| 245 | 253 | res += `\n ${actualLines[i - 2]}`; | |
| 246 | 254 | printedLines++; | |
| 247 | 255 | } | |
@@ -264,7 +272,7 @@ function createErrDiff(actual, expected, operator) { | |||
| 264 | 272 | identical++; | |
| 265 | 273 | // The very first identical line since the last diverging line is be | |
| 266 | 274 | // added to the result. | |
| 267 | - if (identical === 1) { | ||
| 275 | + if (identical <= 2) { | ||
| 268 | 276 | res += `\n ${actualLine}`; | |
| 269 | 277 | printedLines++; | |
| 270 | 278 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,7 +53,7 @@ assert.throws( | |||
| 53 | 53 | code: 'ERR_ASSERTION', | |
| 54 | 54 | message: `${defaultMsgStartFull} ... Lines skipped\n\n` + | |
| 55 | 55 | '+ Uint8Array [\n' + | |
| 56 | - '- Buffer [Uint8Array] [\n 120,\n...\n 10\n ]' | ||
| 56 | + '- Buffer [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' | ||
| 57 | 57 | } | |
| 58 | 58 | ); | |
| 59 | 59 | assert.deepEqual(arr, buf); | |
@@ -66,9 +66,11 @@ assert.deepEqual(arr, buf); | |||
| 66 | 66 | () => assert.deepStrictEqual(buf2, buf), | |
| 67 | 67 | { | |
| 68 | 68 | code: 'ERR_ASSERTION', | |
| 69 | - message: `${defaultMsgStartFull} ... Lines skipped\n\n` + | ||
| 69 | + message: `${defaultMsgStartFull}\n\n` + | ||
| 70 | 70 | ' Buffer [Uint8Array] [\n' + | |
| 71 | - '...\n' + | ||
| 71 | + ' 120,\n' + | ||
| 72 | + ' 121,\n' + | ||
| 73 | + ' 122,\n' + | ||
| 72 | 74 | ' 10,\n' + | |
| 73 | 75 | '+ prop: 1\n' + | |
| 74 | 76 | ' ]' | |
@@ -84,9 +86,11 @@ assert.deepEqual(arr, buf); | |||
| 84 | 86 | () => assert.deepStrictEqual(arr, arr2), | |
| 85 | 87 | { | |
| 86 | 88 | code: 'ERR_ASSERTION', | |
| 87 | - message: `${defaultMsgStartFull} ... Lines skipped\n\n` + | ||
| 89 | + message: `${defaultMsgStartFull}\n\n` + | ||
| 88 | 90 | ' Uint8Array [\n' + | |
| 89 | - '...\n' + | ||
| 91 | + ' 120,\n' + | ||
| 92 | + ' 121,\n' + | ||
| 93 | + ' 122,\n' + | ||
| 90 | 94 | ' 10,\n' + | |
| 91 | 95 | '- prop: 5\n' + | |
| 92 | 96 | ' ]' | |
@@ -932,17 +936,19 @@ assert.deepStrictEqual(obj1, obj2); | |||
| 932 | 936 | ), | |
| 933 | 937 | { | |
| 934 | 938 | message: 'Expected values to be strictly deep-equal:\n' + | |
| 935 | - '+ actual - expected ... Lines skipped\n' + | ||
| 936 | - '\n' + | ||
| 937 | - ' Comparison {\n' + | ||
| 938 | - '...\n' + | ||
| 939 | - " \"+ foo: 'bar'\\n\" +\n" + | ||
| 940 | - "+ \"- foo: 'baz.'\\n\" +\n" + | ||
| 941 | - "- \"- foo: 'baz'\\n\" +\n" + | ||
| 942 | - " ' }',\n" + | ||
| 943 | - "+ operator: 'deepStrictEqual'\n" + | ||
| 944 | - "- operator: 'throws'\n" + | ||
| 945 | - ' }' | ||
| 939 | + '+ actual - expected ... Lines skipped\n' + | ||
| 940 | + '\n' + | ||
| 941 | + ' Comparison {\n' + | ||
| 942 | + " message: 'Expected values to be strictly deep-equal:\\n' +\n" + | ||
| 943 | + '...\n' + | ||
| 944 | + " ' [TypeError: foo] {\\n' +\n" + | ||
| 945 | + " \"+ foo: 'bar'\\n\" +\n" + | ||
| 946 | + "+ \"- foo: 'baz.'\\n\" +\n" + | ||
| 947 | + "- \"- foo: 'baz'\\n\" +\n" + | ||
| 948 | + " ' }',\n" + | ||
| 949 | + "+ operator: 'deepStrictEqual'\n" + | ||
| 950 | + "- operator: 'throws'\n" + | ||
| 951 | + ' }' | ||
| 946 | 952 | } | |
| 947 | 953 | ); | |
| 948 | 954 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -481,12 +481,14 @@ assert.throws( | |||
| 481 | 481 | '', | |
| 482 | 482 | ' [', | |
| 483 | 483 | ' [', | |
| 484 | - '...', | ||
| 484 | + ' [', | ||
| 485 | + ' 1,', | ||
| 485 | 486 | ' 2,', | |
| 486 | 487 | '+ 3', | |
| 487 | 488 | "- '3'", | |
| 488 | 489 | ' ]', | |
| 489 | 490 | '...', | |
| 491 | + ' 4,', | ||
| 490 | 492 | ' 5', | |
| 491 | 493 | ' ]'].join('\n'); | |
| 492 | 494 | assert.throws( | |
@@ -500,10 +502,12 @@ assert.throws( | |||
| 500 | 502 | ' [', | |
| 501 | 503 | ' 1,', | |
| 502 | 504 | '...', | |
| 505 | + ' 1,', | ||
| 503 | 506 | ' 0,', | |
| 504 | 507 | '- 1,', | |
| 505 | 508 | ' 1,', | |
| 506 | 509 | '...', | |
| 510 | + ' 1,', | ||
| 507 | 511 | ' 1', | |
| 508 | 512 | ' ]' | |
| 509 | 513 | ].join('\n'); | |
@@ -520,10 +524,11 @@ assert.throws( | |||
| 520 | 524 | ' [', | |
| 521 | 525 | ' 1,', | |
| 522 | 526 | '...', | |
| 527 | + ' 1,', | ||
| 523 | 528 | ' 0,', | |
| 524 | 529 | '+ 1,', | |
| 525 | 530 | ' 1,', | |
| 526 | - '...', | ||
| 531 | + ' 1,', | ||
| 527 | 532 | ' 1', | |
| 528 | 533 | ' ]' | |
| 529 | 534 | ].join('\n'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ try { | |||
| 9 | 9 | // active. | |
| 10 | 10 | process.env.TERM = 'FOOBAR'; | |
| 11 | 11 | delete process.env.NODE_DISABLE_COLORS; | |
| 12 | - assert.deepStrictEqual([1, 2, 2, 2], [2, 2, 2, 2]); | ||
| 12 | + assert.deepStrictEqual([1, 2, 2, 2, 2], [2, 2, 2, 2, 2]); | ||
| 13 | 13 | } catch (err) { | |
| 14 | 14 | const expected = 'Expected values to be strictly deep-equal:\n' + | |
| 15 | 15 | '\u001b[32m+ actual\u001b[39m \u001b[31m- expected\u001b[39m' + | |
@@ -19,6 +19,7 @@ try { | |||
| 19 | 19 | '\u001b[31m-\u001b[39m 2,\n' + | |
| 20 | 20 | ' 2,\n' + | |
| 21 | 21 | '\u001b[34m...\u001b[39m\n' + | |
| 22 | + ' 2,\n' + | ||
| 22 | 23 | ' 2\n' + | |
| 23 | 24 | ' ]'; | |
| 24 | 25 | assert.strictEqual(err.message, expected); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments