Skip to content

Commit

Permalink
test: confirm that assert truncates long values
Browse files Browse the repository at this point in the history
`assert` has code to truncate values that take more than 128 characters
to display. Add a test for this functionality, as the code is not
currently exercised in the existing tests.

PR-URL: #8134
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and rvagg committed Oct 18, 2016
1 parent 6fdcd7a commit b928f41
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,4 +526,9 @@ testBlockTypeError(assert.doesNotThrow, undefined);
assert.throws(() => { throw 'error'; }, (err) => err === 'error');
assert.throws(() => { throw new Error(); }, (err) => err instanceof Error);

// Long values should be truncated for display.
assert.throws(() => {
assert.strictEqual('A'.repeat(1000), '');
}, new RegExp(`^AssertionError: '${'A'.repeat(127)} === ''$`));

console.log('All OK');

0 comments on commit b928f41

Please sign in to comment.