From d6fece14369ab5d9d64e48ed58cea168f5084a80 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 5 Jul 2017 12:05:24 -0400 Subject: test: add optional throw fn to expectsError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/14089 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Tobias Nießen Reviewed-By: Refael Ackermann --- test/parallel/test-assert-fail.js | 85 ++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'test/parallel/test-assert-fail.js') diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js index 99f7c4e3da..12cff99e66 100644 --- a/test/parallel/test-assert-fail.js +++ b/test/parallel/test-assert-fail.js @@ -17,57 +17,52 @@ assert.throws( ); // One arg = message -assert.throws( - () => { assert.fail('custom message'); }, - common.expectsError({ - code: 'ERR_ASSERTION', - type: assert.AssertionError, - message: 'custom message', - operator: undefined, - actual: undefined, - expected: undefined - }) -); +common.expectsError(() => { + assert.fail('custom message'); +}, { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + message: 'custom message', + operator: undefined, + actual: undefined, + expected: undefined +}); // Two args only, operator defaults to '!=' -assert.throws( - () => { assert.fail('first', 'second'); }, - common.expectsError({ - code: 'ERR_ASSERTION', - type: assert.AssertionError, - message: '\'first\' != \'second\'', - operator: '!=', - actual: 'first', - expected: 'second' - - }) -); +common.expectsError(() => { + assert.fail('first', 'second'); +}, { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + message: '\'first\' != \'second\'', + operator: '!=', + actual: 'first', + expected: 'second' +}); // Three args -assert.throws( - () => { assert.fail('ignored', 'ignored', 'another custom message'); }, - common.expectsError({ - code: 'ERR_ASSERTION', - type: assert.AssertionError, - message: 'another custom message', - operator: undefined, - actual: 'ignored', - expected: 'ignored' - }) -); +common.expectsError(() => { + assert.fail('ignored', 'ignored', 'another custom message'); +}, { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + message: 'another custom message', + operator: undefined, + actual: 'ignored', + expected: 'ignored' +}); // No third arg (but a fourth arg) -assert.throws( - () => { assert.fail('first', 'second', undefined, 'operator'); }, - common.expectsError({ - code: 'ERR_ASSERTION', - type: assert.AssertionError, - message: '\'first\' operator \'second\'', - operator: 'operator', - actual: 'first', - expected: 'second' - }) -); +common.expectsError(() => { + assert.fail('first', 'second', undefined, 'operator'); +}, { + code: 'ERR_ASSERTION', + type: assert.AssertionError, + message: '\'first\' operator \'second\'', + operator: 'operator', + actual: 'first', + expected: 'second' +}); // The stackFrameFunction should exclude the foo frame assert.throws( -- cgit v1.2.3