From e72e3e2e6ea4ed7f2681290b870194340830ba06 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 `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. --- 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 43bd4c770e9cb8..6444bfba6c3324 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(`'${'A'.repeat(127)} === ''`)); + console.log('All OK');