diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-07-05 12:05:24 -0400 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-07-08 16:00:57 -0400 |
commit | d6fece14369ab5d9d64e48ed58cea168f5084a80 (patch) | |
tree | 4c37a3867e4bfbff3ca1d414e72ee50ce2f201c3 /test/parallel/test-assert-fail.js | |
parent | 44483b6898128b05c09635e03e4d7ceaf3efb14c (diff) | |
download | android-node-v8-d6fece14369ab5d9d64e48ed58cea168f5084a80.tar.gz android-node-v8-d6fece14369ab5d9d64e48ed58cea168f5084a80.tar.bz2 android-node-v8-d6fece14369ab5d9d64e48ed58cea168f5084a80.zip |
test: add optional throw fn to expectsError
PR-URL: https://github.com/nodejs/node/pull/14089
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'test/parallel/test-assert-fail.js')
-rw-r--r-- | test/parallel/test-assert-fail.js | 85 |
1 files changed, 40 insertions, 45 deletions
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( |