Browse Source

test: confirm that assert truncates long values

`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: https://github.com/nodejs/node/pull/8134
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v4.x
Rich Trott 8 years ago
committed by Myles Borins
parent
commit
ac83d199fb
  1. 5
      test/parallel/test-assert.js

5
test/parallel/test-assert.js

@ -526,4 +526,9 @@ testBlockTypeError(assert.doesNotThrow, undefined);
assert.throws(() => { throw 'error'; }, (err) => err === 'error'); assert.throws(() => { throw 'error'; }, (err) => err === 'error');
assert.throws(() => { throw new Error(); }, (err) => err instanceof 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'); console.log('All OK');

Loading…
Cancel
Save