Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,13 @@ function formatValue(ctx, value, recurseTimes) {
'byteOffset',
'buffer');
}
} else if (simdFormatters &&
typeof value.constructor === 'function' &&
(formatter = simdFormatters.get(value.constructor))) {
braces = ['[', ']'];
} else {
var promiseInternals = inspectPromise(value);
if (promiseInternals) {
braces = ['{', '}'];
formatter = formatPromise;
} else {
let maybeSimdFormatter;
if (binding.isMapIterator(value)) {
constructor = { name: 'MapIterator' };
braces = ['{', '}'];
Expand All @@ -507,6 +504,11 @@ function formatValue(ctx, value, recurseTimes) {
braces = ['{', '}'];
empty = false;
formatter = formatCollectionIterator;
} else if (simdFormatters &&
typeof constructor === 'function' &&
(maybeSimdFormatter = simdFormatters.get(constructor))) {
braces = ['[', ']'];
formatter = maybeSimdFormatter;
} else {
// Unset the constructor to prevent "Object {...}" for ordinary objects.
if (constructor && constructor.name === 'Object')
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-util-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const symbol = Symbol('foo');
assert.equal(util.format(), '');
assert.equal(util.format(''), '');
assert.equal(util.format([]), '[]');
assert.equal(util.format([0]), '[ 0 ]');
assert.equal(util.format({}), '{}');
assert.equal(util.format({foo: 42}), '{ foo: 42 }');
assert.equal(util.format(null), 'null');
assert.equal(util.format(true), 'true');
assert.equal(util.format(false), 'false');
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-util-inspect-simd.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ if (typeof SIMD.Uint8x16 === 'function') {
inspect(SIMD.Uint8x16()),
'Uint8x16 [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]');
}

// Tests from test-inspect.js that should not fail with --harmony_simd.
assert.strictEqual(inspect([]), '[]');
assert.strictEqual(inspect([0]), '[ 0 ]');
assert.strictEqual(inspect({}), '{}');
assert.strictEqual(inspect({foo: 42}), '{ foo: 42 }');
assert.strictEqual(inspect(null), 'null');
assert.strictEqual(inspect(true), 'true');
assert.strictEqual(inspect(false), 'false');