| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d15cdc6 commit 28b2d8a
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,13 +58,13 @@ const bufferMaxSizeMsg = common.expectsError({ | |||
| 58 | 58 | assert.throws(function() { | |
| 59 | 59 | SlowBuffer(Infinity); | |
| 60 | 60 | }, bufferMaxSizeMsg); | |
| 61 | - assert.throws(function() { | ||
| 61 | + common.expectsError(function() { | ||
| 62 | 62 | SlowBuffer(-1); | |
| 63 | - }, common.expectsError({ | ||
| 63 | + }, { | ||
| 64 | 64 | code: 'ERR_INVALID_OPT_VALUE', | |
| 65 | 65 | type: RangeError, | |
| 66 | 66 | message: 'The value "-1" is invalid for option "size"' | |
| 67 | - })); | ||
| 67 | + }); | ||
| 68 | 68 | ||
| 69 | 69 | assert.throws(function() { | |
| 70 | 70 | SlowBuffer(buffer.kMaxLength + 1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,17 +84,17 @@ assert.strictEqual(rangeBuffer.toString({ toString: function() { | |||
| 84 | 84 | } }), 'abc'); | |
| 85 | 85 | ||
| 86 | 86 | // try toString() with 0 and null as the encoding | |
| 87 | - assert.throws(() => { | ||
| 87 | + common.expectsError(() => { | ||
| 88 | 88 | rangeBuffer.toString(0, 1, 2); | |
| 89 | - }, common.expectsError({ | ||
| 89 | + }, { | ||
| 90 | 90 | code: 'ERR_UNKNOWN_ENCODING', | |
| 91 | 91 | type: TypeError, | |
| 92 | 92 | message: 'Unknown encoding: 0' | |
| 93 | - })); | ||
| 94 | - assert.throws(() => { | ||
| 93 | + }); | ||
| 94 | + common.expectsError(() => { | ||
| 95 | 95 | rangeBuffer.toString(null, 1, 2); | |
| 96 | - }, common.expectsError({ | ||
| 96 | + }, { | ||
| 97 | 97 | code: 'ERR_UNKNOWN_ENCODING', | |
| 98 | 98 | type: TypeError, | |
| 99 | 99 | message: 'Unknown encoding: null' | |
| 100 | - })); | ||
| 100 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,9 +5,9 @@ const assert = require('assert'); | |||
| 5 | 5 | const cp = require('child_process'); | |
| 6 | 6 | ||
| 7 | 7 | function fail(proc, args) { | |
| 8 | - assert.throws(() => { | ||
| 8 | + common.expectsError(() => { | ||
| 9 | 9 | proc.send.apply(proc, args); | |
| 10 | - }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError })); | ||
| 10 | + }, { code: 'ERR_INVALID_ARG_TYPE', type: TypeError }); | ||
| 11 | 11 | } | |
| 12 | 12 | ||
| 13 | 13 | let target = process; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,9 @@ if (process.argv[2] === 'child') { | |||
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | 31 | // Verify that an error is thrown for unknown signals. | |
| 32 | - assert.throws(() => { | ||
| 32 | + common.expectsError(() => { | ||
| 33 | 33 | spawn('SIG_NOT_A_REAL_SIGNAL'); | |
| 34 | - }, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL', type: TypeError })); | ||
| 34 | + }, { code: 'ERR_UNKNOWN_SIGNAL', type: TypeError }); | ||
| 35 | 35 | ||
| 36 | 36 | // Verify that the default kill signal is SIGTERM. | |
| 37 | 37 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,6 @@ options = { stdio: 'ignore' }; | |||
| 40 | 40 | child = spawnSync('cat', [], options); | |
| 41 | 41 | assert.deepStrictEqual(options, { stdio: 'ignore' }); | |
| 42 | 42 | ||
| 43 | - assert.throws(() => { | ||
| 43 | + common.expectsError(() => { | ||
| 44 | 44 | common.spawnPwd({ stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'ipc'] }); | |
| 45 | - }, common.expectsError({ code: 'ERR_IPC_ONE_PIPE', type: Error })); | ||
| 45 | + }, { code: 'ERR_IPC_ONE_PIPE', type: Error }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,8 +26,9 @@ assert.throws(() => _validateStdio(600), expectedError); | |||
| 26 | 26 | ||
| 27 | 27 | // should throw if stdio has ipc and sync is true | |
| 28 | 28 | const stdio2 = ['ipc', 'ipc', 'ipc']; | |
| 29 | - assert.throws(() => _validateStdio(stdio2, true), | ||
| 30 | - common.expectsError({ code: 'ERR_IPC_SYNC_FORK', type: Error })); | ||
| 29 | + common.expectsError(() => _validateStdio(stdio2, true), | ||
| 30 | + { code: 'ERR_IPC_SYNC_FORK', type: Error } | ||
| 31 | + ); | ||
| 31 | 32 | ||
| 32 | 33 | { | |
| 33 | 34 | const stdio3 = [process.stdin, process.stdout, process.stderr]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,12 +45,12 @@ assert.throws(function() { | |||
| 45 | 45 | }, /^TypeError: Invalid minimum value: \/foo\/$/); | |
| 46 | 46 | ||
| 47 | 47 | // assert.fail() tests | |
| 48 | - assert.throws( | ||
| 48 | + common.expectsError( | ||
| 49 | 49 | () => { assert.fail('fhqwhgads'); }, | |
| 50 | - common.expectsError({ | ||
| 50 | + { | ||
| 51 | 51 | code: 'ERR_ASSERTION', | |
| 52 | 52 | message: /^fhqwhgads$/ | |
| 53 | - })); | ||
| 53 | + }); | ||
| 54 | 54 | ||
| 55 | 55 | const fnOnce = common.mustCall(() => {}); | |
| 56 | 56 | fnOnce(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,13 +37,13 @@ assert.strictEqual('function', typeof Console); | |||
| 37 | 37 | ||
| 38 | 38 | // make sure that the Console constructor throws | |
| 39 | 39 | // when not given a writable stream instance | |
| 40 | - assert.throws( | ||
| 40 | + common.expectsError( | ||
| 41 | 41 | () => { new Console(); }, | |
| 42 | - common.expectsError({ | ||
| 42 | + { | ||
| 43 | 43 | code: 'ERR_CONSOLE_WRITABLE_STREAM', | |
| 44 | 44 | type: TypeError, | |
| 45 | 45 | message: /stdout/ | |
| 46 | - }) | ||
| 46 | + } | ||
| 47 | 47 | ); | |
| 48 | 48 | ||
| 49 | 49 | // Console constructor should throw if stderr exists but is not writable | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,13 +27,13 @@ const dgram = require('dgram'); | |||
| 27 | 27 | const socket = dgram.createSocket('udp4'); | |
| 28 | 28 | ||
| 29 | 29 | socket.on('listening', common.mustCall(() => { | |
| 30 | - assert.throws(() => { | ||
| 30 | + common.expectsError(() => { | ||
| 31 | 31 | socket.bind(); | |
| 32 | - }, common.expectsError({ | ||
| 32 | + }, { | ||
| 33 | 33 | code: 'ERR_SOCKET_ALREADY_BOUND', | |
| 34 | 34 | type: Error, | |
| 35 | 35 | message: /^Socket is already bound$/ | |
| 36 | - })); | ||
| 36 | + }); | ||
| 37 | 37 | ||
| 38 | 38 | socket.close(); | |
| 39 | 39 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,12 +6,12 @@ const UDP = process.binding('udp_wrap').UDP; | |||
| 6 | 6 | const _createSocketHandle = dgram._createSocketHandle; | |
| 7 | 7 | ||
| 8 | 8 | // Throws if an "existing fd" is passed in. | |
| 9 | - assert.throws(() => { | ||
| 9 | + common.expectsError(() => { | ||
| 10 | 10 | _createSocketHandle(common.localhostIPv4, 0, 'udp4', 42); | |
| 11 | - }, common.expectsError({ | ||
| 11 | + }, { | ||
| 12 | 12 | code: 'ERR_ASSERTION', | |
| 13 | 13 | message: /^false == true$/ | |
| 14 | - })); | ||
| 14 | + }); | ||
| 15 | 15 | ||
| 16 | 16 | { | |
| 17 | 17 | // Create a handle that is not bound. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments