From a0971b7da0c5440590d982500c4daa8a7ee8b04c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 16 Aug 2016 20:47:24 -0700 Subject: [PATCH] test: confirm that assert truncates long values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-assert.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 43bd4c770e..c1eb87f3ed 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -528,4 +528,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');