| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 10f7169 commit efa0bd8
395 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,6 @@ rules: | |||
| 14 | 14 | # Custom rules in tools/eslint-rules | |
| 15 | 15 | node-core/prefer-assert-iferror: error | |
| 16 | 16 | node-core/prefer-assert-methods: error | |
| 17 | - node-core/prefer-common-expectserror: error | ||
| 18 | 17 | node-core/prefer-common-mustnotcall: error | |
| 19 | 18 | node-core/crypto-check: error | |
| 20 | 19 | node-core/eslint-check: error | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const skipMessage = 'intensive toString tests due to memory confinements'; | |||
| 5 | 5 | if (!common.enoughTestMem) | |
| 6 | 6 | common.skip(skipMessage); | |
| 7 | 7 | ||
| 8 | + const assert = require('assert'); | ||
| 8 | 9 | const binding = require(`./build/${common.buildType}/binding`); | |
| 9 | 10 | ||
| 10 | 11 | // v8 fails silently if string length > v8::String::kMaxLength | |
@@ -25,11 +26,11 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) | |||
| 25 | 26 | common.skip(skipMessage); | |
| 26 | 27 | ||
| 27 | 28 | const stringLengthHex = kStringMaxLength.toString(16); | |
| 28 | - common.expectsError(() => { | ||
| 29 | + assert.throws(() => { | ||
| 29 | 30 | buf.toString('ascii'); | |
| 30 | 31 | }, { | |
| 31 | 32 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 32 | 33 | 'characters', | |
| 33 | 34 | code: 'ERR_STRING_TOO_LONG', | |
| 34 | - type: Error | ||
| 35 | + name: 'Error' | ||
| 35 | 36 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const skipMessage = 'intensive toString tests due to memory confinements'; | |||
| 5 | 5 | if (!common.enoughTestMem) | |
| 6 | 6 | common.skip(skipMessage); | |
| 7 | 7 | ||
| 8 | + const assert = require('assert'); | ||
| 8 | 9 | const binding = require(`./build/${common.buildType}/binding`); | |
| 9 | 10 | ||
| 10 | 11 | // v8 fails silently if string length > v8::String::kMaxLength | |
@@ -25,11 +26,11 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) | |||
| 25 | 26 | common.skip(skipMessage); | |
| 26 | 27 | ||
| 27 | 28 | const stringLengthHex = kStringMaxLength.toString(16); | |
| 28 | - common.expectsError(() => { | ||
| 29 | + assert.throws(() => { | ||
| 29 | 30 | buf.toString('base64'); | |
| 30 | 31 | }, { | |
| 31 | 32 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 32 | 33 | 'characters', | |
| 33 | 34 | code: 'ERR_STRING_TOO_LONG', | |
| 34 | - type: Error | ||
| 35 | + name: 'Error' | ||
| 35 | 36 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,13 +27,13 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) | |||
| 27 | 27 | common.skip(skipMessage); | |
| 28 | 28 | ||
| 29 | 29 | const stringLengthHex = kStringMaxLength.toString(16); | |
| 30 | - common.expectsError(() => { | ||
| 30 | + assert.throws(() => { | ||
| 31 | 31 | buf.toString('latin1'); | |
| 32 | 32 | }, { | |
| 33 | 33 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 34 | 34 | 'characters', | |
| 35 | 35 | code: 'ERR_STRING_TOO_LONG', | |
| 36 | - type: Error | ||
| 36 | + name: 'Error' | ||
| 37 | 37 | }); | |
| 38 | 38 | ||
| 39 | 39 | // FIXME: Free the memory early to avoid OOM. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const skipMessage = 'intensive toString tests due to memory confinements'; | |||
| 5 | 5 | if (!common.enoughTestMem) | |
| 6 | 6 | common.skip(skipMessage); | |
| 7 | 7 | ||
| 8 | + const assert = require('assert'); | ||
| 8 | 9 | const binding = require(`./build/${common.buildType}/binding`); | |
| 9 | 10 | ||
| 10 | 11 | // v8 fails silently if string length > v8::String::kMaxLength | |
@@ -25,11 +26,11 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) | |||
| 25 | 26 | common.skip(skipMessage); | |
| 26 | 27 | ||
| 27 | 28 | const stringLengthHex = kStringMaxLength.toString(16); | |
| 28 | - common.expectsError(() => { | ||
| 29 | + assert.throws(() => { | ||
| 29 | 30 | buf.toString('hex'); | |
| 30 | 31 | }, { | |
| 31 | 32 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 32 | 33 | 'characters', | |
| 33 | 34 | code: 'ERR_STRING_TOO_LONG', | |
| 34 | - type: Error | ||
| 35 | + name: 'Error' | ||
| 35 | 36 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,19 +35,19 @@ assert.throws(() => { | |||
| 35 | 35 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 36 | 36 | 'characters', | |
| 37 | 37 | code: 'ERR_STRING_TOO_LONG', | |
| 38 | - type: Error | ||
| 38 | + name: 'Error' | ||
| 39 | 39 | })(e); | |
| 40 | 40 | return true; | |
| 41 | 41 | } else { | |
| 42 | 42 | return true; | |
| 43 | 43 | } | |
| 44 | 44 | }); | |
| 45 | 45 | ||
| 46 | - common.expectsError(() => { | ||
| 46 | + assert.throws(() => { | ||
| 47 | 47 | buf.toString('utf8'); | |
| 48 | 48 | }, { | |
| 49 | 49 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 50 | 50 | 'characters', | |
| 51 | 51 | code: 'ERR_STRING_TOO_LONG', | |
| 52 | - type: Error | ||
| 52 | + name: 'Error' | ||
| 53 | 53 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ const skipMessage = 'intensive toString tests due to memory confinements'; | |||
| 5 | 5 | if (!common.enoughTestMem) | |
| 6 | 6 | common.skip(skipMessage); | |
| 7 | 7 | ||
| 8 | + const assert = require('assert'); | ||
| 8 | 9 | const binding = require(`./build/${common.buildType}/binding`); | |
| 9 | 10 | ||
| 10 | 11 | // v8 fails silently if string length > v8::String::kMaxLength | |
@@ -26,11 +27,11 @@ if (!binding.ensureAllocation(2 * kStringMaxLength)) | |||
| 26 | 27 | ||
| 27 | 28 | const stringLengthHex = kStringMaxLength.toString(16); | |
| 28 | 29 | ||
| 29 | - common.expectsError(() => { | ||
| 30 | + assert.throws(() => { | ||
| 30 | 31 | buf.toString('utf16le'); | |
| 31 | 32 | }, { | |
| 32 | 33 | message: `Cannot create a string longer than 0x${stringLengthHex} ` + | |
| 33 | 34 | 'characters', | |
| 34 | 35 | code: 'ERR_STRING_TOO_LONG', | |
| 35 | - type: Error | ||
| 36 | + name: 'Error' | ||
| 36 | 37 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,9 +18,9 @@ if (process.argv[2] === 'child') { | |||
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | [null, undefined, 1, Date, {}, []].forEach((i) => { | |
| 21 | - common.expectsError(() => new Foo(i), { | ||
| 21 | + assert.throws(() => new Foo(i), { | ||
| 22 | 22 | code: 'ERR_INVALID_ARG_TYPE', | |
| 23 | - type: TypeError | ||
| 23 | + name: 'TypeError' | ||
| 24 | 24 | }); | |
| 25 | 25 | }); | |
| 26 | 26 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,16 +12,16 @@ const { checkInvocations } = require('./hook-checks'); | |||
| 12 | 12 | const hooks = initHooks(); | |
| 13 | 13 | hooks.enable(); | |
| 14 | 14 | ||
| 15 | - common.expectsError( | ||
| 15 | + assert.throws( | ||
| 16 | 16 | () => new AsyncResource(), { | |
| 17 | 17 | code: 'ERR_INVALID_ARG_TYPE', | |
| 18 | - type: TypeError, | ||
| 18 | + name: 'TypeError', | ||
| 19 | 19 | }); | |
| 20 | - common.expectsError(() => { | ||
| 20 | + assert.throws(() => { | ||
| 21 | 21 | new AsyncResource('invalid_trigger_id', { triggerAsyncId: null }); | |
| 22 | 22 | }, { | |
| 23 | 23 | code: 'ERR_INVALID_ASYNC_ID', | |
| 24 | - type: RangeError, | ||
| 24 | + name: 'RangeError', | ||
| 25 | 25 | }); | |
| 26 | 26 | ||
| 27 | 27 | assert.strictEqual( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,44 +71,17 @@ the `unhandledRejection` hook is directly used by the test. | |||
| 71 | 71 | ||
| 72 | 72 | Indicates if there is more than 1gb of total memory. | |
| 73 | 73 | ||
| 74 | - ### expectsError(\[fn, \]settings\[, exact\]) | ||
| 75 | - * `fn` [<Function>][] a function that should throw. | ||
| 76 | - * `settings` [<Object>][] | ||
| 77 | - that must contain the `code` property plus any of the other following | ||
| 78 | - properties (some properties only apply for `AssertionError`): | ||
| 79 | - * `code` [<string>][] | ||
| 80 | - expected error must have this value for its `code` property. | ||
| 81 | - * `type` [<Function>][] | ||
| 82 | - expected error must be an instance of `type` and must be an Error subclass. | ||
| 83 | - * `message` [<string>][] or [<RegExp>][] | ||
| 84 | - if a string is provided for `message`, expected error must have it for its | ||
| 85 | - `message` property; if a regular expression is provided for `message`, the | ||
| 86 | - regular expression must match the `message` property of the expected error. | ||
| 87 | - * `name` [<string>][] | ||
| 88 | - expected error must have this value for its `name` property. | ||
| 89 | - * `info` <Object> expected error must have the same `info` property | ||
| 90 | - that is deeply equal to this value. | ||
| 91 | - * `generatedMessage` [<string>][] | ||
| 92 | - (`AssertionError` only) expected error must have this value for its | ||
| 93 | - `generatedMessage` property. | ||
| 94 | - * `actual` <any> | ||
| 95 | - (`AssertionError` only) expected error must have this value for its | ||
| 96 | - `actual` property. | ||
| 97 | - * `expected` <any> | ||
| 98 | - (`AssertionError` only) expected error must have this value for its | ||
| 99 | - `expected` property. | ||
| 100 | - * `operator` <any> | ||
| 101 | - (`AssertionError` only) expected error must have this value for its | ||
| 102 | - `operator` property. | ||
| 74 | + ### expectsError(validator\[, exact\]) | ||
| 75 | + * `validator` [<Object>][] | [<RegExp>][] | [<Function>][] | | ||
| 76 | + [<Error>][] The validator behaves identical to | ||
| 77 | + `assert.throws(fn, validator)`. | ||
| 103 | 78 | * `exact` [<number>][] default = 1 | |
| 104 | - * return [<Function>][] | ||
| 79 | + * return [<Function>][] A callback function that expects an error. | ||
| 105 | 80 | ||
| 106 | - If `fn` is provided, it will be passed to `assert.throws` as first argument | ||
| 107 | - and `undefined` will be returned. | ||
| 108 | - Otherwise a function suitable as callback or for use as a validation function | ||
| 109 | - passed as the second argument to `assert.throws()` will be returned. If the | ||
| 110 | - returned function has not been called exactly `exact` number of times when the | ||
| 111 | - test is complete, then the test will fail. | ||
| 81 | + A function suitable as callback to validate callback based errors. The error is | ||
| 82 | + validated using `assert.throws(() => { throw error; }, validator)`. If the | ||
| 83 | + returned function has not been called exactly `exact` number of times when the | ||
| 84 | + test is complete, then the test will fail. | ||
| 112 | 85 | ||
| 113 | 86 | ### expectWarning(name\[, expected\[, code\]\]) | |
| 114 | 87 | * `name` [<string>][] | [<Object>][] | |
@@ -929,6 +902,7 @@ See [the WPT tests README][] for details. | |||
| 929 | 902 | [<ArrayBufferView>]: https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView | |
| 930 | 903 | [<Buffer>]: https://nodejs.org/api/buffer.html#buffer_class_buffer | |
| 931 | 904 | [<BufferSource>]: https://developer.mozilla.org/en-US/docs/Web/API/BufferSource | |
| 905 | + [<Error>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error | ||
| 932 | 906 | [<Function>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function | |
| 933 | 907 | [<Object>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object | |
| 934 | 908 | [<RegExp>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp | |
| Back | FazBrowse Home | New Git URL |
0 commit comments