| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,12 +17,12 @@ common.expectsError( | |||
| 17 | 17 | code: 'ERR_INVALID_ARG_TYPE', | |
| 18 | 18 | type: TypeError, | |
| 19 | 19 | }); | |
| 20 | - assert.throws(() => { | ||
| 20 | + common.expectsError(() => { | ||
| 21 | 21 | new AsyncResource('invalid_trigger_id', { triggerAsyncId: null }); | |
| 22 | - }, common.expectsError({ | ||
| 22 | + }, { | ||
| 23 | 23 | code: 'ERR_INVALID_ASYNC_ID', | |
| 24 | 24 | type: RangeError, | |
| 25 | - })); | ||
| 25 | + }); | ||
| 26 | 26 | ||
| 27 | 27 | assert.strictEqual( | |
| 28 | 28 | new AsyncResource('default_trigger_id').triggerAsyncId(), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | + /* eslint-disable prefer-common-expectserror */ | ||
| 4 | + | ||
| 3 | 5 | const common = require('../common'); | |
| 4 | 6 | const assert = require('assert'); | |
| 5 | 7 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,9 @@ | |||
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | + | ||
| 24 | + /* eslint-disable prefer-common-expectserror */ | ||
| 25 | + | ||
| 23 | 26 | const common = require('../common'); | |
| 24 | 27 | const assert = require('assert'); | |
| 25 | 28 | const a = assert; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -974,12 +974,11 @@ assert.strictEqual(SlowBuffer.prototype.offset, undefined); | |||
| 974 | 974 | } | |
| 975 | 975 | ||
| 976 | 976 | // ParseArrayIndex() should reject values that don't fit in a 32 bits size_t. | |
| 977 | - assert.throws(() => { | ||
| 977 | + common.expectsError(() => { | ||
| 978 | 978 | const a = Buffer.alloc(1); | |
| 979 | 979 | const b = Buffer.alloc(1); | |
| 980 | 980 | a.copy(b, 0, 0x100000000, 0x100000001); | |
| 981 | - }, common.expectsError( | ||
| 982 | - { code: undefined, type: RangeError, message: 'Index out of range' })); | ||
| 981 | + }, { code: undefined, type: RangeError, message: 'Index out of range' }); | ||
| 983 | 982 | ||
| 984 | 983 | // Unpooled buffer (replaces SlowBuffer) | |
| 985 | 984 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -421,21 +421,19 @@ common.expectsError(() => { | |||
| 421 | 421 | ||
| 422 | 422 | // Testing process.binding. Make sure "end" is properly checked for -1 wrap | |
| 423 | 423 | // around. | |
| 424 | - assert.throws(() => { | ||
| 424 | + common.expectsError(() => { | ||
| 425 | 425 | process.binding('buffer').fill(Buffer.alloc(1), 1, 1, -2, 1); | |
| 426 | - }, common.expectsError( | ||
| 427 | - { code: undefined, type: RangeError, message: 'Index out of range' })); | ||
| 426 | + }, { code: undefined, type: RangeError, message: 'Index out of range' }); | ||
| 428 | 427 | ||
| 429 | 428 | // Test that bypassing 'length' won't cause an abort. | |
| 430 | - assert.throws(() => { | ||
| 429 | + common.expectsError(() => { | ||
| 431 | 430 | const buf = new Buffer('w00t'); | |
| 432 | 431 | Object.defineProperty(buf, 'length', { | |
| 433 | 432 | value: 1337, | |
| 434 | 433 | enumerable: true | |
| 435 | 434 | }); | |
| 436 | 435 | buf.fill(''); | |
| 437 | - }, common.expectsError( | ||
| 438 | - { code: undefined, type: RangeError, message: 'Index out of range' })); | ||
| 436 | + }, { code: undefined, type: RangeError, message: 'Index out of range' }); | ||
| 439 | 437 | ||
| 440 | 438 | assert.deepStrictEqual( | |
| 441 | 439 | Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,17 +47,17 @@ common.expectsError( | |||
| 47 | 47 | ); | |
| 48 | 48 | ||
| 49 | 49 | // Console constructor should throw if stderr exists but is not writable | |
| 50 | - assert.throws( | ||
| 50 | + common.expectsError( | ||
| 51 | 51 | () => { | |
| 52 | 52 | out.write = () => {}; | |
| 53 | 53 | err.write = undefined; | |
| 54 | 54 | new Console(out, err); | |
| 55 | 55 | }, | |
| 56 | - common.expectsError({ | ||
| 56 | + { | ||
| 57 | 57 | code: 'ERR_CONSOLE_WRITABLE_STREAM', | |
| 58 | 58 | type: TypeError, | |
| 59 | 59 | message: /stderr/ | |
| 60 | - }) | ||
| 60 | + } | ||
| 61 | 61 | ); | |
| 62 | 62 | ||
| 63 | 63 | out.write = err.write = (d) => {}; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,20 +205,20 @@ assert.doesNotThrow(() => { | |||
| 205 | 205 | }, common.mustCall()); | |
| 206 | 206 | }); | |
| 207 | 207 | ||
| 208 | - assert.throws(() => dns.lookupService('0.0.0.0'), common.expectsError({ | ||
| 208 | + common.expectsError(() => dns.lookupService('0.0.0.0'), { | ||
| 209 | 209 | code: 'ERR_MISSING_ARGS', | |
| 210 | 210 | type: TypeError, | |
| 211 | 211 | message: 'The "host", "port", and "callback" arguments must be specified' | |
| 212 | - })); | ||
| 212 | + }); | ||
| 213 | 213 | ||
| 214 | 214 | const invalidHost = 'fasdfdsaf'; | |
| 215 | - assert.throws(() => { | ||
| 215 | + common.expectsError(() => { | ||
| 216 | 216 | dns.lookupService(invalidHost, 0, common.mustNotCall()); | |
| 217 | - }, common.expectsError({ | ||
| 217 | + }, { | ||
| 218 | 218 | code: 'ERR_INVALID_OPT_VALUE', | |
| 219 | 219 | type: TypeError, | |
| 220 | 220 | message: `The value "${invalidHost}" is invalid for option "host"` | |
| 221 | - })); | ||
| 221 | + }); | ||
| 222 | 222 | ||
| 223 | 223 | const portErr = (port) => { | |
| 224 | 224 | common.expectsError( | |
@@ -238,9 +238,9 @@ portErr(undefined); | |||
| 238 | 238 | portErr(65538); | |
| 239 | 239 | portErr('test'); | |
| 240 | 240 | ||
| 241 | - assert.throws(() => { | ||
| 241 | + common.expectsError(() => { | ||
| 242 | 242 | dns.lookupService('0.0.0.0', 80, null); | |
| 243 | - }, common.expectsError({ | ||
| 243 | + }, { | ||
| 244 | 244 | code: 'ERR_INVALID_CALLBACK', | |
| 245 | 245 | type: TypeError | |
| 246 | - })); | ||
| 246 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,80 +21,80 @@ assert.strictEqual( | |||
| 21 | 21 | typeof ServerResponse.prototype._implicitHeader, 'function'); | |
| 22 | 22 | ||
| 23 | 23 | // validateHeader | |
| 24 | - assert.throws(() => { | ||
| 24 | + common.expectsError(() => { | ||
| 25 | 25 | const outgoingMessage = new OutgoingMessage(); | |
| 26 | 26 | outgoingMessage.setHeader(); | |
| 27 | - }, common.expectsError({ | ||
| 27 | + }, { | ||
| 28 | 28 | code: 'ERR_INVALID_HTTP_TOKEN', | |
| 29 | 29 | type: TypeError, | |
| 30 | 30 | message: 'Header name must be a valid HTTP token ["undefined"]' | |
| 31 | - })); | ||
| 31 | + }); | ||
| 32 | 32 | ||
| 33 | - assert.throws(() => { | ||
| 33 | + common.expectsError(() => { | ||
| 34 | 34 | const outgoingMessage = new OutgoingMessage(); | |
| 35 | 35 | outgoingMessage.setHeader('test'); | |
| 36 | - }, common.expectsError({ | ||
| 36 | + }, { | ||
| 37 | 37 | code: 'ERR_MISSING_ARGS', | |
| 38 | 38 | type: TypeError, | |
| 39 | 39 | message: 'The "value" argument must be specified' | |
| 40 | - })); | ||
| 40 | + }); | ||
| 41 | 41 | ||
| 42 | - assert.throws(() => { | ||
| 42 | + common.expectsError(() => { | ||
| 43 | 43 | const outgoingMessage = new OutgoingMessage(); | |
| 44 | 44 | outgoingMessage.setHeader(404); | |
| 45 | - }, common.expectsError({ | ||
| 45 | + }, { | ||
| 46 | 46 | code: 'ERR_INVALID_HTTP_TOKEN', | |
| 47 | 47 | type: TypeError, | |
| 48 | 48 | message: 'Header name must be a valid HTTP token ["404"]' | |
| 49 | - })); | ||
| 49 | + }); | ||
| 50 | 50 | ||
| 51 | - assert.throws(() => { | ||
| 51 | + common.expectsError(() => { | ||
| 52 | 52 | const outgoingMessage = new OutgoingMessage(); | |
| 53 | 53 | outgoingMessage.setHeader.call({ _header: 'test' }, 'test', 'value'); | |
| 54 | - }, common.expectsError({ | ||
| 54 | + }, { | ||
| 55 | 55 | code: 'ERR_HTTP_HEADERS_SENT', | |
| 56 | 56 | type: Error, | |
| 57 | 57 | message: 'Cannot set headers after they are sent to the client' | |
| 58 | - })); | ||
| 58 | + }); | ||
| 59 | 59 | ||
| 60 | - assert.throws(() => { | ||
| 60 | + common.expectsError(() => { | ||
| 61 | 61 | const outgoingMessage = new OutgoingMessage(); | |
| 62 | 62 | outgoingMessage.setHeader('200', 'あ'); | |
| 63 | - }, common.expectsError({ | ||
| 63 | + }, { | ||
| 64 | 64 | code: 'ERR_INVALID_CHAR', | |
| 65 | 65 | type: TypeError, | |
| 66 | 66 | message: 'Invalid character in header content ["200"]' | |
| 67 | - })); | ||
| 67 | + }); | ||
| 68 | 68 | ||
| 69 | 69 | // write | |
| 70 | - assert.throws(() => { | ||
| 70 | + common.expectsError(() => { | ||
| 71 | 71 | const outgoingMessage = new OutgoingMessage(); | |
| 72 | 72 | outgoingMessage.write(); | |
| 73 | - }, common.expectsError({ | ||
| 73 | + }, { | ||
| 74 | 74 | code: 'ERR_METHOD_NOT_IMPLEMENTED', | |
| 75 | 75 | type: Error, | |
| 76 | 76 | message: 'The _implicitHeader() method is not implemented' | |
| 77 | - })); | ||
| 77 | + }); | ||
| 78 | 78 | ||
| 79 | 79 | assert(OutgoingMessage.prototype.write.call({ _header: 'test' })); | |
| 80 | 80 | ||
| 81 | - assert.throws(() => { | ||
| 81 | + common.expectsError(() => { | ||
| 82 | 82 | const outgoingMessage = new OutgoingMessage(); | |
| 83 | 83 | outgoingMessage.write.call({ _header: 'test', _hasBody: 'test' }); | |
| 84 | - }, common.expectsError({ | ||
| 84 | + }, { | ||
| 85 | 85 | code: 'ERR_INVALID_ARG_TYPE', | |
| 86 | 86 | type: TypeError, | |
| 87 | 87 | message: 'The first argument must be one of type string or Buffer' | |
| 88 | - })); | ||
| 88 | + }); | ||
| 89 | 89 | ||
| 90 | - assert.throws(() => { | ||
| 90 | + common.expectsError(() => { | ||
| 91 | 91 | const outgoingMessage = new OutgoingMessage(); | |
| 92 | 92 | outgoingMessage.write.call({ _header: 'test', _hasBody: 'test' }, 1); | |
| 93 | - }, common.expectsError({ | ||
| 93 | + }, { | ||
| 94 | 94 | code: 'ERR_INVALID_ARG_TYPE', | |
| 95 | 95 | type: TypeError, | |
| 96 | 96 | message: 'The first argument must be one of type string or Buffer' | |
| 97 | - })); | ||
| 97 | + }); | ||
| 98 | 98 | ||
| 99 | 99 | // addTrailers() | |
| 100 | 100 | // The `Error` comes from the JavaScript engine so confirm that it is a | |
@@ -105,20 +105,20 @@ assert.throws(() => { | |||
| 105 | 105 | outgoingMessage.addTrailers(); | |
| 106 | 106 | }, TypeError); | |
| 107 | 107 | ||
| 108 | - assert.throws(() => { | ||
| 108 | + common.expectsError(() => { | ||
| 109 | 109 | const outgoingMessage = new OutgoingMessage(); | |
| 110 | 110 | outgoingMessage.addTrailers({ 'あ': 'value' }); | |
| 111 | - }, common.expectsError({ | ||
| 111 | + }, { | ||
| 112 | 112 | code: 'ERR_INVALID_HTTP_TOKEN', | |
| 113 | 113 | type: TypeError, | |
| 114 | 114 | message: 'Trailer name must be a valid HTTP token ["あ"]' | |
| 115 | - })); | ||
| 115 | + }); | ||
| 116 | 116 | ||
| 117 | - assert.throws(() => { | ||
| 117 | + common.expectsError(() => { | ||
| 118 | 118 | const outgoingMessage = new OutgoingMessage(); | |
| 119 | 119 | outgoingMessage.addTrailers({ 404: 'あ' }); | |
| 120 | - }, common.expectsError({ | ||
| 120 | + }, { | ||
| 121 | 121 | code: 'ERR_INVALID_CHAR', | |
| 122 | 122 | type: TypeError, | |
| 123 | 123 | message: 'Invalid character in trailer content ["404"]' | |
| 124 | - })); | ||
| 124 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ | |||
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | if (!common.hasCrypto) | |
| 5 | 5 | common.skip('missing crypto'); | |
| 6 | - const assert = require('assert'); | ||
| 7 | 6 | const http2 = require('http2'); | |
| 8 | 7 | ||
| 9 | 8 | // Check if correct errors are emitted when wrong type of data is passed | |
@@ -40,19 +39,19 @@ server.listen(0, common.mustCall(() => { | |||
| 40 | 39 | return; | |
| 41 | 40 | } | |
| 42 | 41 | ||
| 43 | - assert.throws( | ||
| 42 | + common.expectsError( | ||
| 44 | 43 | () => client.request({ | |
| 45 | 44 | ':method': 'CONNECT', | |
| 46 | 45 | ':authority': `localhost:${port}` | |
| 47 | 46 | }, { | |
| 48 | 47 | [option]: types[type] | |
| 49 | 48 | }), | |
| 50 | - common.expectsError({ | ||
| 49 | + { | ||
| 51 | 50 | type: TypeError, | |
| 52 | 51 | code: 'ERR_INVALID_OPT_VALUE', | |
| 53 | 52 | message: `The value "${String(types[type])}" is invalid ` + | |
| 54 | 53 | `for option "${option}"` | |
| 55 | - }) | ||
| 54 | + } | ||
| 56 | 55 | ); | |
| 57 | 56 | }); | |
| 58 | 57 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,36 +55,36 @@ server.listen(0, common.mustCall(() => { | |||
| 55 | 55 | const client = http2.connect(`http://localhost:${proxy.address().port}`); | |
| 56 | 56 | ||
| 57 | 57 | // confirm that :authority is required and :scheme & :path are forbidden | |
| 58 | - assert.throws( | ||
| 58 | + common.expectsError( | ||
| 59 | 59 | () => client.request({ | |
| 60 | 60 | [HTTP2_HEADER_METHOD]: 'CONNECT' | |
| 61 | 61 | }), | |
| 62 | - common.expectsError({ | ||
| 62 | + { | ||
| 63 | 63 | code: 'ERR_HTTP2_CONNECT_AUTHORITY', | |
| 64 | 64 | message: ':authority header is required for CONNECT requests' | |
| 65 | - }) | ||
| 65 | + } | ||
| 66 | 66 | ); | |
| 67 | - assert.throws( | ||
| 67 | + common.expectsError( | ||
| 68 | 68 | () => client.request({ | |
| 69 | 69 | [HTTP2_HEADER_METHOD]: 'CONNECT', | |
| 70 | 70 | [HTTP2_HEADER_AUTHORITY]: `localhost:${port}`, | |
| 71 | 71 | [HTTP2_HEADER_SCHEME]: 'http' | |
| 72 | 72 | }), | |
| 73 | - common.expectsError({ | ||
| 73 | + { | ||
| 74 | 74 | code: 'ERR_HTTP2_CONNECT_SCHEME', | |
| 75 | 75 | message: 'The :scheme header is forbidden for CONNECT requests' | |
| 76 | - }) | ||
| 76 | + } | ||
| 77 | 77 | ); | |
| 78 | - assert.throws( | ||
| 78 | + common.expectsError( | ||
| 79 | 79 | () => client.request({ | |
| 80 | 80 | [HTTP2_HEADER_METHOD]: 'CONNECT', | |
| 81 | 81 | [HTTP2_HEADER_AUTHORITY]: `localhost:${port}`, | |
| 82 | 82 | [HTTP2_HEADER_PATH]: '/' | |
| 83 | 83 | }), | |
| 84 | - common.expectsError({ | ||
| 84 | + { | ||
| 85 | 85 | code: 'ERR_HTTP2_CONNECT_PATH', | |
| 86 | 86 | message: 'The :path header is forbidden for CONNECT requests' | |
| 87 | - }) | ||
| 87 | + } | ||
| 88 | 88 | ); | |
| 89 | 89 | ||
| 90 | 90 | // valid CONNECT request | |
| Back | FazBrowse Home | New Git URL |
0 commit comments