diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-06-27 06:00:35 +0200 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-07-02 22:44:09 -0400 |
commit | 0455fff880b9a4d25ee24150aedafa51808926ee (patch) | |
tree | 93f120c4f9e08ba9756b30fb57446ebd20bd0c91 /test/parallel/test-assert-fail.js | |
parent | 7a2b3e2b6cc92b2d694041ab852e860f459dadcd (diff) | |
download | android-node-v8-0455fff880b9a4d25ee24150aedafa51808926ee.tar.gz android-node-v8-0455fff880b9a4d25ee24150aedafa51808926ee.tar.bz2 android-node-v8-0455fff880b9a4d25ee24150aedafa51808926ee.zip |
assert: refactor the code
1. Rename private functions
2. Use destructuring
3. Remove obsolete comments
PR-URL: https://github.com/nodejs/node/pull/13862
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test/parallel/test-assert-fail.js')
-rw-r--r-- | test/parallel/test-assert-fail.js | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js index 1b72310a16..99f7c4e3da 100644 --- a/test/parallel/test-assert-fail.js +++ b/test/parallel/test-assert-fail.js @@ -1,53 +1,76 @@ 'use strict'; + const common = require('../common'); const assert = require('assert'); -// no args +// No args assert.throws( () => { assert.fail(); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'Failed' + message: 'Failed', + operator: undefined, + actual: undefined, + expected: undefined }) ); -// one arg = message +// One arg = message assert.throws( () => { assert.fail('custom message'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'custom message' + message: 'custom message', + operator: undefined, + actual: undefined, + expected: undefined }) ); -// two args only, operator defaults to '!=' +// Two args only, operator defaults to '!=' assert.throws( () => { assert.fail('first', 'second'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: '\'first\' != \'second\'' + message: '\'first\' != \'second\'', + operator: '!=', + actual: 'first', + expected: 'second' + }) ); -// three args +// Three args assert.throws( () => { assert.fail('ignored', 'ignored', 'another custom message'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'another custom message' + message: 'another custom message', + operator: undefined, + actual: 'ignored', + expected: 'ignored' }) ); -// no third arg (but a fourth arg) +// 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\'' + message: '\'first\' operator \'second\'', + operator: 'operator', + actual: 'first', + expected: 'second' }) ); + +// The stackFrameFunction should exclude the foo frame +assert.throws( + function foo() { assert.fail('first', 'second', 'message', '!==', foo); }, + (err) => !/foo/m.test(err.stack) +); |