GeezerVison is showing github.com — util: add (typed) array length to the default output · nodejs/node@cc19d08
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js +25-32Lines changed: 25 additions & 32 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -119,6 +119,9 @@ const setSizeGetter = uncurryThis( | 119 | 119 | ObjectGetOwnPropertyDescriptor(SetPrototype, 'size').get); | 120 | 120 | const mapSizeGetter = uncurryThis( | 121 | 121 | ObjectGetOwnPropertyDescriptor(MapPrototype, 'size').get); | | 122 | +const typedArraySizeGetter = uncurryThis( | | 123 | + ObjectGetOwnPropertyDescriptor( | | 124 | + ObjectGetPrototypeOf(Uint8Array.prototype), 'length').get); | 122 | 125 |
| 123 | 126 | let hexSlice; | 124 | 127 |
| @@ -564,18 +567,18 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, isProto, output) { | 564 | 567 | } while (++depth !== 3); | 565 | 568 | } | 566 | 569 |
| 567 | | -function getPrefix(constructor, tag, fallback) { | | 570 | +function getPrefix(constructor, tag, fallback, size = '') { | 568 | 571 | if (constructor === null) { | 569 | 572 | if (tag !== '') { | 570 | | - return `[${fallback}: null prototype] [${tag}] `; | | 573 | + return `[${fallback}${size}: null prototype] [${tag}] `; | 571 | 574 | } | 572 | | - return `[${fallback}: null prototype] `; | | 575 | + return `[${fallback}${size}: null prototype] `; | 573 | 576 | } | 574 | 577 |
| 575 | 578 | if (tag !== '' && constructor !== tag) { | 576 | | - return `${constructor} [${tag}] `; | | 579 | + return `${constructor}${size} [${tag}] `; | 577 | 580 | } | 578 | | - return `${constructor} `; | | 581 | + return `${constructor}${size} `; | 579 | 582 | } | 580 | 583 |
| 581 | 584 | // Look up the keys of the object. | @@ -760,58 +763,48 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | 760 | 763 | if (value[SymbolIterator] || constructor === null) { | 761 | 764 | noIterator = false; | 762 | 765 | if (ArrayIsArray(value)) { | 763 | | - keys = getOwnNonIndexProperties(value, filter); | 764 | 766 | // Only set the constructor for non ordinary ("Array [...]") arrays. | 765 | | - const prefix = getPrefix(constructor, tag, 'Array'); | 766 | | - braces = [`${prefix === 'Array ' ? '' : prefix}[`, ']']; | | 767 | + const prefix = (constructor !== 'Array' || tag !== '') ? | | 768 | + getPrefix(constructor, tag, 'Array', `(${value.length})`) : | | 769 | + ''; | | 770 | + keys = getOwnNonIndexProperties(value, filter); | | 771 | + braces = [`${prefix}[`, ']']; | 767 | 772 | if (value.length === 0 && keys.length === 0 && protoProps === undefined) | 768 | 773 | return `${braces[0]}]`; | 769 | 774 | extrasType = kArrayExtrasType; | 770 | 775 | formatter = formatArray; | 771 | 776 | } else if (isSet(value)) { | 772 | 777 | const size = setSizeGetter(value); | | 778 | + const prefix = getPrefix(constructor, tag, 'Set'); | 773 | 779 | keys = getKeys(value, ctx.showHidden); | 774 | | - let prefix = ''; | 775 | | - if (constructor !== null) { | 776 | | - if (constructor === tag) | 777 | | - tag = ''; | 778 | | - prefix = getPrefix(`${constructor}`, tag, ''); | 779 | | - formatter = formatSet.bind(null, value, size); | 780 | | - } else { | 781 | | - prefix = getPrefix(constructor, tag, 'Set'); | 782 | | - formatter = formatSet.bind(null, SetPrototypeValues(value), size); | 783 | | - } | | 780 | + formatter = constructor !== null ? | | 781 | + formatSet.bind(null, value, size) : | | 782 | + formatSet.bind(null, SetPrototypeValues(value), size); | 784 | 783 | if (size === 0 && keys.length === 0 && protoProps === undefined) | 785 | 784 | return `${prefix}{}`; | 786 | 785 | braces = [`${prefix}{`, '}']; | 787 | 786 | } else if (isMap(value)) { | 788 | 787 | const size = mapSizeGetter(value); | | 788 | + const prefix = getPrefix(constructor, tag, 'Map'); | 789 | 789 | keys = getKeys(value, ctx.showHidden); | 790 | | - let prefix = ''; | 791 | | - if (constructor !== null) { | 792 | | - if (constructor === tag) | 793 | | - tag = ''; | 794 | | - prefix = getPrefix(`${constructor}`, tag, ''); | 795 | | - formatter = formatMap.bind(null, value, size); | 796 | | - } else { | 797 | | - prefix = getPrefix(constructor, tag, 'Map'); | 798 | | - formatter = formatMap.bind(null, MapPrototypeEntries(value), size); | 799 | | - } | | 790 | + formatter = constructor !== null ? | | 791 | + formatMap.bind(null, value, size) : | | 792 | + formatMap.bind(null, MapPrototypeEntries(value), size); | 800 | 793 | if (size === 0 && keys.length === 0 && protoProps === undefined) | 801 | 794 | return `${prefix}{}`; | 802 | 795 | braces = [`${prefix}{`, '}']; | 803 | 796 | } else if (isTypedArray(value)) { | 804 | 797 | keys = getOwnNonIndexProperties(value, filter); | 805 | 798 | let bound = value; | 806 | | - let prefix = ''; | | 799 | + let fallback = ''; | 807 | 800 | if (constructor === null) { | 808 | 801 | const constr = findTypedConstructor(value); | 809 | | - prefix = getPrefix(constructor, tag, constr.name); | | 802 | + fallback = constr.name; | 810 | 803 | // Reconstruct the array information. | 811 | 804 | bound = new constr(value); | 812 | | - } else { | 813 | | - prefix = getPrefix(constructor, tag); | 814 | 805 | } | | 806 | + const size = typedArraySizeGetter(value); | | 807 | + const prefix = getPrefix(constructor, tag, fallback, `(${size})`); | 815 | 808 | braces = [`${prefix}[`, ']']; | 816 | 809 | if (value.length === 0 && keys.length === 0 && !ctx.showHidden) | 817 | 810 | return `${braces[0]}]`; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-assert-deep.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,8 +51,8 @@ assert.throws( | 51 | 51 | { | 52 | 52 | code: 'ERR_ASSERTION', | 53 | 53 | message: `${defaultMsgStartFull} ... Lines skipped\n\n` + | 54 | | - '+ Uint8Array [\n' + | 55 | | - '- Buffer [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' | | 54 | + '+ Uint8Array(4) [\n' + | | 55 | + '- Buffer(4) [Uint8Array] [\n 120,\n...\n 122,\n 10\n ]' | 56 | 56 | } | 57 | 57 | ); | 58 | 58 | assert.deepEqual(arr, buf); | @@ -66,7 +66,7 @@ assert.deepEqual(arr, buf); | 66 | 66 | { | 67 | 67 | code: 'ERR_ASSERTION', | 68 | 68 | message: `${defaultMsgStartFull}\n\n` + | 69 | | - ' Buffer [Uint8Array] [\n' + | | 69 | + ' Buffer(4) [Uint8Array] [\n' + | 70 | 70 | ' 120,\n' + | 71 | 71 | ' 121,\n' + | 72 | 72 | ' 122,\n' + | @@ -86,7 +86,7 @@ assert.deepEqual(arr, buf); | 86 | 86 | { | 87 | 87 | code: 'ERR_ASSERTION', | 88 | 88 | message: `${defaultMsgStartFull}\n\n` + | 89 | | - ' Uint8Array [\n' + | | 89 | + ' Uint8Array(4) [\n' + | 90 | 90 | ' 120,\n' + | 91 | 91 | ' 121,\n' + | 92 | 92 | ' 122,\n' + | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-buffer-inspect.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,7 +58,7 @@ b.inspect = undefined; | 58 | 58 | b.prop = new Uint8Array(0); | 59 | 59 | assert.strictEqual( | 60 | 60 | util.inspect(b), | 61 | | - '<Buffer 31 32, inspect: undefined, prop: Uint8Array []>' | | 61 | + '<Buffer 31 32, inspect: undefined, prop: Uint8Array(0) []>' | 62 | 62 | ); | 63 | 63 |
| 64 | 64 | b = Buffer.alloc(0); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-fs-read-empty-buffer.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ assert.throws( | 15 | 15 | { | 16 | 16 | code: 'ERR_INVALID_ARG_VALUE', | 17 | 17 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | 18 | | - 'Received Uint8Array []' | | 18 | + 'Received Uint8Array(0) []' | 19 | 19 | } | 20 | 20 | ); | 21 | 21 |
| @@ -24,7 +24,7 @@ assert.throws( | 24 | 24 | { | 25 | 25 | code: 'ERR_INVALID_ARG_VALUE', | 26 | 26 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | 27 | | - 'Received Uint8Array []' | | 27 | + 'Received Uint8Array(0) []' | 28 | 28 | } | 29 | 29 | ); | 30 | 30 |
| @@ -35,7 +35,7 @@ assert.throws( | 35 | 35 | { | 36 | 36 | code: 'ERR_INVALID_ARG_VALUE', | 37 | 37 | message: 'The argument \'buffer\' is empty and cannot be written. ' + | 38 | | - 'Received Uint8Array []' | | 38 | + 'Received Uint8Array(0) []' | 39 | 39 | } | 40 | 40 | ); | 41 | 41 | })(); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-util-format.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -158,7 +158,7 @@ assert.strictEqual(util.format('%s', () => 5), '() => 5'); | 158 | 158 | class Foobar extends Array { aaa = true; } | 159 | 159 | assert.strictEqual( | 160 | 160 | util.format('%s', new Foobar(5)), | 161 | | - 'Foobar [ <5 empty items>, aaa: true ]' | | 161 | + 'Foobar(5) [ <5 empty items>, aaa: true ]' | 162 | 162 | ); | 163 | 163 |
| 164 | 164 | // Subclassing: | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js +35-32Lines changed: 35 additions & 32 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -126,7 +126,7 @@ assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': 2 } } }, false, 1), | 126 | 126 | '{ a: { b: [Object] } }'); | 127 | 127 | assert.strictEqual(util.inspect({ 'a': { 'b': ['c'] } }, false, 1), | 128 | 128 | '{ a: { b: [Array] } }'); | 129 | | -assert.strictEqual(util.inspect(new Uint8Array(0)), 'Uint8Array []'); | | 129 | +assert.strictEqual(util.inspect(new Uint8Array(0)), 'Uint8Array(0) []'); | 130 | 130 | assert(inspect(new Uint8Array(0), { showHidden: true }).includes('[buffer]')); | 131 | 131 | assert.strictEqual( | 132 | 132 | util.inspect( | @@ -263,7 +263,7 @@ assert(!/Object/.test( | 263 | 263 | array[1] = 97; | 264 | 264 | assert.strictEqual( | 265 | 265 | util.inspect(array, { showHidden: true }), | 266 | | - `${constructor.name} [\n` + | | 266 | + `${constructor.name}(${length}) [\n` + | 267 | 267 | ' 65,\n' + | 268 | 268 | ' 97,\n' + | 269 | 269 | ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + | @@ -273,7 +273,7 @@ assert(!/Object/.test( | 273 | 273 | ` [buffer]: ArrayBuffer { byteLength: ${byteLength} }\n]`); | 274 | 274 | assert.strictEqual( | 275 | 275 | util.inspect(array, false), | 276 | | - `${constructor.name} [ 65, 97 ]` | | 276 | + `${constructor.name}(${length}) [ 65, 97 ]` | 277 | 277 | ); | 278 | 278 | }); | 279 | 279 |
| @@ -297,7 +297,7 @@ assert(!/Object/.test( | 297 | 297 | array[1] = 97; | 298 | 298 | assert.strictEqual( | 299 | 299 | util.inspect(array, true), | 300 | | - `${constructor.name} [\n` + | | 300 | + `${constructor.name}(${length}) [\n` + | 301 | 301 | ' 65,\n' + | 302 | 302 | ' 97,\n' + | 303 | 303 | ` [BYTES_PER_ELEMENT]: ${constructor.BYTES_PER_ELEMENT},\n` + | @@ -307,7 +307,7 @@ assert(!/Object/.test( | 307 | 307 | ` [buffer]: ArrayBuffer { byteLength: ${byteLength} }\n]`); | 308 | 308 | assert.strictEqual( | 309 | 309 | util.inspect(array, false), | 310 | | - `${constructor.name} [ 65, 97 ]` | | 310 | + `${constructor.name}(${length}) [ 65, 97 ]` | 311 | 311 | ); | 312 | 312 | }); | 313 | 313 |
| @@ -397,11 +397,11 @@ assert.strictEqual( | 397 | 397 | arr[49] = 'I win'; | 398 | 398 | assert.strictEqual( | 399 | 399 | util.inspect(arr), | 400 | | - "CustomArray [ <49 empty items>, 'I win' ]" | | 400 | + "CustomArray(50) [ <49 empty items>, 'I win' ]" | 401 | 401 | ); | 402 | 402 | assert.strictEqual( | 403 | 403 | util.inspect(arr, { showHidden: true }), | 404 | | - 'CustomArray [\n' + | | 404 | + 'CustomArray(50) [\n' + | 405 | 405 | ' <49 empty items>,\n' + | 406 | 406 | " 'I win',\n" + | 407 | 407 | ' [length]: 50,\n' + | @@ -1291,7 +1291,7 @@ if (typeof Symbol !== 'undefined') { | 1291 | 1291 | assert.strictEqual(util.inspect(x), | 1292 | 1292 | 'ObjectSubclass { foo: 42 }'); | 1293 | 1293 | assert.strictEqual(util.inspect(new ArraySubclass(1, 2, 3)), | 1294 | | - 'ArraySubclass [ 1, 2, 3 ]'); | | 1294 | + 'ArraySubclass(3) [ 1, 2, 3 ]'); | 1295 | 1295 | assert.strictEqual(util.inspect(new SetSubclass([1, 2, 3])), | 1296 | 1296 | 'SetSubclass [Set] { 1, 2, 3 }'); | 1297 | 1297 | assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])), | @@ -1387,7 +1387,7 @@ if (typeof Symbol !== 'undefined') { | 1387 | 1387 | assert(util.inspect(x).endsWith('1 more item\n]')); | 1388 | 1388 | assert(!util.inspect(x, { maxArrayLength: 101 }).includes('1 more item')); | 1389 | 1389 | assert.strictEqual(util.inspect(x, { maxArrayLength: 0 }), | 1390 | | - 'Uint8Array [ ... 101 more items ]'); | | 1390 | + 'Uint8Array(101) [ ... 101 more items ]'); | 1391 | 1391 | assert(!util.inspect(x, { maxArrayLength: null }).includes('1 more item')); | 1392 | 1392 | assert(util.inspect(x, { maxArrayLength: Infinity }).endsWith(' 0, 0\n]')); | 1393 | 1393 | } | @@ -1672,7 +1672,7 @@ util.inspect(process); | 1672 | 1672 | ' ],', | 1673 | 1673 | ' [length]: 1', | 1674 | 1674 | ' ]', | 1675 | | - ' } => Uint8Array [', | | 1675 | + ' } => Uint8Array(0) [', | 1676 | 1676 | ' [BYTES_PER_ELEMENT]: 1,', | 1677 | 1677 | ' [length]: 0,', | 1678 | 1678 | ' [byteLength]: 0,', | @@ -1689,7 +1689,7 @@ util.inspect(process); | 1689 | 1689 | ' [length]: 2', | 1690 | 1690 | ' ]', | 1691 | 1691 | ' } => [Map Iterator] {', | 1692 | | - ' Uint8Array [', | | 1692 | + ' Uint8Array(0) [', | 1693 | 1693 | ' [BYTES_PER_ELEMENT]: 1,', | 1694 | 1694 | ' [length]: 0,', | 1695 | 1695 | ' [byteLength]: 0,', | @@ -1720,15 +1720,15 @@ util.inspect(process); | 1720 | 1720 | ' ],', | 1721 | 1721 | ' [length]: 1', | 1722 | 1722 | ' ]', | 1723 | | - ' } => Uint8Array [', | | 1723 | + ' } => Uint8Array(0) [', | 1724 | 1724 | ' [BYTES_PER_ELEMENT]: 1,', | 1725 | 1725 | ' [length]: 0,', | 1726 | 1726 | ' [byteLength]: 0,', | 1727 | 1727 | ' [byteOffset]: 0,', | 1728 | 1728 | ' [buffer]: ArrayBuffer { byteLength: 0, foo: true }', | 1729 | 1729 | ' ],', | 1730 | 1730 | ' [Set Iterator] { [ 1, 2, [length]: 2 ] } => [Map Iterator] {', | 1731 | | - ' Uint8Array [', | | 1731 | + ' Uint8Array(0) [', | 1732 | 1732 | ' [BYTES_PER_ELEMENT]: 1,', | 1733 | 1733 | ' [length]: 0,', | 1734 | 1734 | ' [byteLength]: 0,', | @@ -1756,7 +1756,7 @@ util.inspect(process); | 1756 | 1756 | ' [length]: 2 ],', | 1757 | 1757 | ' [size]: 1 },', | 1758 | 1758 | ' [length]: 2 ],', | 1759 | | - ' [length]: 1 ] } => Uint8Array [', | | 1759 | + ' [length]: 1 ] } => Uint8Array(0) [', | 1760 | 1760 | ' [BYTES_PER_ELEMENT]: 1,', | 1761 | 1761 | ' [length]: 0,', | 1762 | 1762 | ' [byteLength]: 0,', | @@ -1768,7 +1768,7 @@ util.inspect(process); | 1768 | 1768 | ' [ 1,', | 1769 | 1769 | ' 2,', | 1770 | 1770 | ' [length]: 2 ] } => [Map Iterator] {', | 1771 | | - ' Uint8Array [', | | 1771 | + ' Uint8Array(0) [', | 1772 | 1772 | ' [BYTES_PER_ELEMENT]: 1,', | 1773 | 1773 | ' [length]: 0,', | 1774 | 1774 | ' [byteLength]: 0,', | @@ -1946,7 +1946,7 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); | 1946 | 1946 | [new Set([1, 2]).entries(), '[Set Entries] { [ 1, 1 ], [ 2, 2 ] }'], | 1947 | 1947 | [new Map([[1, 2]]).keys(), '[Map Iterator] { 1 }'], | 1948 | 1948 | [new Date(2000), '1970-01-01T00:00:02.000Z'], | 1949 | | - [new Uint8Array(2), 'Uint8Array [ 0, 0 ]'], | | 1949 | + [new Uint8Array(2), 'Uint8Array(2) [ 0, 0 ]'], | 1950 | 1950 | [new Promise((resolve) => setTimeout(resolve, 10)), 'Promise { <pending> }'], | 1951 | 1951 | [new WeakSet(), 'WeakSet { <items unknown> }'], | 1952 | 1952 | [new WeakMap(), 'WeakMap { <items unknown> }'], | @@ -1972,23 +1972,23 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); | 1972 | 1972 |
| 1973 | 1973 | // Verify that having no prototype still produces nice results. | 1974 | 1974 | [ | 1975 | | - [[1, 3, 4], '[Array: null prototype] [ 1, 3, 4 ]'], | | 1975 | + [[1, 3, 4], '[Array(3): null prototype] [ 1, 3, 4 ]'], | 1976 | 1976 | [new Set([1, 2]), '[Set: null prototype] { 1, 2 }'], | 1977 | 1977 | [new Map([[1, 2]]), '[Map: null prototype] { 1 => 2 }'], | 1978 | 1978 | [new Promise((resolve) => setTimeout(resolve, 10)), | 1979 | 1979 | '[Promise: null prototype] { <pending> }'], | 1980 | 1980 | [new WeakSet(), '[WeakSet: null prototype] { <items unknown> }'], | 1981 | 1981 | [new WeakMap(), '[WeakMap: null prototype] { <items unknown> }'], | 1982 | | - [new Uint8Array(2), '[Uint8Array: null prototype] [ 0, 0 ]'], | 1983 | | - [new Uint16Array(2), '[Uint16Array: null prototype] [ 0, 0 ]'], | 1984 | | - [new Uint32Array(2), '[Uint32Array: null prototype] [ 0, 0 ]'], | 1985 | | - [new Int8Array(2), '[Int8Array: null prototype] [ 0, 0 ]'], | 1986 | | - [new Int16Array(2), '[Int16Array: null prototype] [ 0, 0 ]'], | 1987 | | - [new Int32Array(2), '[Int32Array: null prototype] [ 0, 0 ]'], | 1988 | | - [new Float32Array(2), '[Float32Array: null prototype] [ 0, 0 ]'], | 1989 | | - [new Float64Array(2), '[Float64Array: null prototype] [ 0, 0 ]'], | 1990 | | - [new BigInt64Array(2), '[BigInt64Array: null prototype] [ 0n, 0n ]'], | 1991 | | - [new BigUint64Array(2), '[BigUint64Array: null prototype] [ 0n, 0n ]'], | | 1982 | + [new Uint8Array(2), '[Uint8Array(2): null prototype] [ 0, 0 ]'], | | 1983 | + [new Uint16Array(2), '[Uint16Array(2): null prototype] [ 0, 0 ]'], | | 1984 | + [new Uint32Array(2), '[Uint32Array(2): null prototype] [ 0, 0 ]'], | | 1985 | + [new Int8Array(2), '[Int8Array(2): null prototype] [ 0, 0 ]'], | | 1986 | + [new Int16Array(2), '[Int16Array(2): null prototype] [ 0, 0 ]'], | | 1987 | + [new Int32Array(2), '[Int32Array(2): null prototype] [ 0, 0 ]'], | | 1988 | + [new Float32Array(2), '[Float32Array(2): null prototype] [ 0, 0 ]'], | | 1989 | + [new Float64Array(2), '[Float64Array(2): null prototype] [ 0, 0 ]'], | | 1990 | + [new BigInt64Array(2), '[BigInt64Array(2): null prototype] [ 0n, 0n ]'], | | 1991 | + [new BigUint64Array(2), '[BigUint64Array(2): null prototype] [ 0n, 0n ]'], | 1992 | 1992 | [new ArrayBuffer(16), '[ArrayBuffer: null prototype] {\n' + | 1993 | 1993 | ' [Uint8Contents]: <00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>,\n' + | 1994 | 1994 | ' byteLength: undefined\n}'], | @@ -2026,8 +2026,10 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); | 2026 | 2026 | class Foo extends base {} | 2027 | 2027 | const value = new Foo(...input); | 2028 | 2028 | const symbol = value[Symbol.toStringTag]; | 2029 | | - const expected = `Foo ${symbol ? `[${symbol}] ` : ''}${rawExpected}`; | 2030 | | - const expectedWithoutProto = `[${base.name}: null prototype] ${rawExpected}`; | | 2029 | + const size = base.name.includes('Array') ? `(${input[0]})` : ''; | | 2030 | + const expected = `Foo${size} ${symbol ? `[${symbol}] ` : ''}${rawExpected}`; | | 2031 | + const expectedWithoutProto = | | 2032 | + `[${base.name}${size}: null prototype] ${rawExpected}`; | 2031 | 2033 | assert.strictEqual(util.inspect(value), expected); | 2032 | 2034 | value.foo = 'bar'; | 2033 | 2035 | assert.notStrictEqual(util.inspect(value), expected); | @@ -2050,8 +2052,9 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); | 2050 | 2052 | assert.strictEqual(inspect(1n), '1n'); | 2051 | 2053 | assert.strictEqual(inspect(Object(-1n)), '[BigInt: -1n]'); | 2052 | 2054 | assert.strictEqual(inspect(Object(13n)), '[BigInt: 13n]'); | 2053 | | -assert.strictEqual(inspect(new BigInt64Array([0n])), 'BigInt64Array [ 0n ]'); | 2054 | | -assert.strictEqual(inspect(new BigUint64Array([0n])), 'BigUint64Array [ 0n ]'); | | 2055 | +assert.strictEqual(inspect(new BigInt64Array([0n])), 'BigInt64Array(1) [ 0n ]'); | | 2056 | +assert.strictEqual( | | 2057 | + inspect(new BigUint64Array([0n])), 'BigUint64Array(1) [ 0n ]'); | 2055 | 2058 |
| 2056 | 2059 | // Verify non-enumerable keys get escaped. | 2057 | 2060 | { | @@ -2170,7 +2173,7 @@ assert.strictEqual( | 2170 | 2173 | Object.setPrototypeOf(obj, value); | 2171 | 2174 | assert.strictEqual( | 2172 | 2175 | util.inspect(obj), | 2173 | | - 'Object <[Array: null prototype] []> { a: true }' | | 2176 | + 'Object <[Array(0): null prototype] []> { a: true }' | 2174 | 2177 | ); | 2175 | 2178 |
| 2176 | 2179 | function StorageObject() {} | |
|