-
-
Notifications
You must be signed in to change notification settings - Fork 35k
errors: extract type detection & use in ERR_INVALID_RETURN_VALUE
#43558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
74be6fe
572c162
4a4204e
b757821
4871b85
96dbd0e
d2eded5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
ERR_INVALID_RETURN_VALUE
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| // Flags: --expose-internals | ||
|
|
||
| import '../common/index.mjs'; | ||
| import { strictEqual } from 'node:assert'; | ||
| import errorsModule from 'internal/errors'; | ||
|
|
||
|
|
||
| const { determineSpecificType } = errorsModule; | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(1n), | ||
| 'type bigint (1n)', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(false), | ||
| 'type boolean (false)', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(2), | ||
| 'type number (2)', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(NaN), | ||
| 'type number (NaN)', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(Infinity), | ||
| 'type number (Infinity)', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(''), | ||
| "type string ('')", | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(Symbol('foo')), | ||
| 'type symbol (Symbol(foo))', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(function foo() {}), | ||
| 'function foo', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(null), | ||
| 'null', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(undefined), | ||
| 'undefined', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType([]), | ||
| 'an instance of Array', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(new Array(0)), | ||
JakobJingleheimer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'an instance of Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new BigInt64Array(0)), | ||
| 'an instance of BigInt64Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new BigUint64Array(0)), | ||
| 'an instance of BigUint64Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Int8Array(0)), | ||
| 'an instance of Int8Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Int16Array(0)), | ||
| 'an instance of Int16Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Int32Array(0)), | ||
| 'an instance of Int32Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Float32Array(0)), | ||
| 'an instance of Float32Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Float64Array(0)), | ||
| 'an instance of Float64Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Uint8Array(0)), | ||
| 'an instance of Uint8Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Uint8ClampedArray(0)), | ||
| 'an instance of Uint8ClampedArray', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Uint16Array(0)), | ||
| 'an instance of Uint16Array', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new Uint32Array(0)), | ||
| 'an instance of Uint32Array', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(new Date()), | ||
| 'an instance of Date', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(new Map()), | ||
| 'an instance of Map', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new WeakMap()), | ||
| 'an instance of WeakMap', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(Object.create(null)), | ||
| 'an instance of Object', | ||
|
||
| ); | ||
| strictEqual( | ||
| determineSpecificType({}), | ||
| 'an instance of Object', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(Promise.resolve('foo')), | ||
| 'an instance of Promise', | ||
| ); | ||
|
|
||
| strictEqual( | ||
| determineSpecificType(new Set()), | ||
| 'an instance of Set', | ||
| ); | ||
| strictEqual( | ||
| determineSpecificType(new WeakSet()), | ||
| 'an instance of WeakSet', | ||
| ); | ||
Uh oh!
There was an error while loading. Please reload this page.