aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-stream-buffer-list.js8
-rw-r--r--test/parallel/test-util-inspect-proxy.js16
-rw-r--r--test/parallel/test-util-inspect.js26
3 files changed, 31 insertions, 19 deletions
diff --git a/test/parallel/test-stream-buffer-list.js b/test/parallel/test-stream-buffer-list.js
index ddbff452de..87c9d2a2bb 100644
--- a/test/parallel/test-stream-buffer-list.js
+++ b/test/parallel/test-stream-buffer-list.js
@@ -3,6 +3,7 @@
require('../common');
const assert = require('assert');
const BufferList = require('internal/streams/BufferList');
+const util = require('util');
// Test empty buffer list.
const emptyList = new BufferList();
@@ -25,3 +26,10 @@ assert.strictEqual(list.join(','), 'foo');
const shifted = list.shift();
assert.strictEqual(shifted, 'foo');
assert.deepStrictEqual(list, new BufferList());
+
+const tmp = util.inspect.defaultOptions.colors;
+util.inspect.defaultOptions = { colors: true };
+assert.strictEqual(
+ util.inspect(list),
+ 'BufferList { length: \u001b[33m0\u001b[39m }');
+util.inspect.defaultOptions = { colors: tmp };
diff --git a/test/parallel/test-util-inspect-proxy.js b/test/parallel/test-util-inspect-proxy.js
index 63527986b1..8c76285499 100644
--- a/test/parallel/test-util-inspect-proxy.js
+++ b/test/parallel/test-util-inspect-proxy.js
@@ -48,13 +48,17 @@ const expected1 = 'Proxy [ {}, {} ]';
const expected2 = 'Proxy [ Proxy [ {}, {} ], {} ]';
const expected3 = 'Proxy [ Proxy [ Proxy [ {}, {} ], {} ], Proxy [ {}, {} ] ]';
const expected4 = 'Proxy [ Proxy [ {}, {} ], Proxy [ Proxy [ {}, {} ], {} ] ]';
-const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], {} ],' +
+const expected5 = 'Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ],' +
' Proxy [ {}, {} ] ],\n Proxy [ Proxy [ {}, {} ]' +
- ', Proxy [ Proxy [Array], {} ] ] ]';
-const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [Array], Proxy [Array]' +
- ' ],\n Proxy [ Proxy [Array], Proxy [Array] ] ],\n' +
- ' Proxy [ Proxy [ Proxy [Array], Proxy [Array] ],\n' +
- ' Proxy [ Proxy [Array], Proxy [Array] ] ] ]';
+ ', Proxy [ Proxy [ {}, {} ], {} ] ] ]';
+const expected6 = 'Proxy [ Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ], ' +
+ 'Proxy [ {}, {} ] ],\n' +
+ ' Proxy [ Proxy [ {}, {} ], ' +
+ 'Proxy [ Proxy [ {}, {} ], {} ] ] ],\n' +
+ ' Proxy [ Proxy [ Proxy [ Proxy [ {}, {} ], {} ], ' +
+ 'Proxy [ {}, {} ] ],\n' +
+ ' Proxy [ Proxy [ {}, {} ], ' +
+ 'Proxy [ Proxy [ {}, {} ], {} ] ] ] ]';
assert.strictEqual(
util.inspect(proxy1, { showProxy: true, depth: null }),
expected1);
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js
index 335ba09bd7..35e85f6fdd 100644
--- a/test/parallel/test-util-inspect.js
+++ b/test/parallel/test-util-inspect.js
@@ -68,7 +68,7 @@ assert.strictEqual(util.inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
assert.strictEqual(util.inspect({ 'a': {} }), '{ a: {} }');
assert.strictEqual(util.inspect({ 'a': { 'b': 2 } }), '{ a: { b: 2 } }');
assert.strictEqual(util.inspect({ 'a': { 'b': { 'c': { 'd': 2 } } } }),
- '{ a: { b: { c: [Object] } } }');
+ '{ a: { b: { c: { d: 2 } } } }');
assert.strictEqual(
util.inspect({ 'a': { 'b': { 'c': { 'd': 2 } } } }, false, null),
'{ a: { b: { c: { d: 2 } } } }');
@@ -106,7 +106,7 @@ assert.strictEqual(util.inspect((new JSStream())._externalStream),
assert.strictEqual(util.inspect({ a: regexp }, false, 0), '{ a: /regexp/ }');
}
-assert(/Object/.test(
+assert(!/Object/.test(
util.inspect({ a: { a: { a: { a: {} } } } }, undefined, undefined, true)
));
assert(!/Object/.test(
@@ -1012,15 +1012,15 @@ if (typeof Symbol !== 'undefined') {
// Empty and circular before depth
{
const arr = [[[[]]]];
- assert.strictEqual(util.inspect(arr), '[ [ [ [] ] ] ]');
+ assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ [] ] ] ]');
arr[0][0][0][0] = [];
- assert.strictEqual(util.inspect(arr), '[ [ [ [Array] ] ] ]');
+ assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ [Array] ] ] ]');
arr[0][0][0] = {};
- assert.strictEqual(util.inspect(arr), '[ [ [ {} ] ] ]');
+ assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ {} ] ] ]');
arr[0][0][0] = { a: 2 };
- assert.strictEqual(util.inspect(arr), '[ [ [ [Object] ] ] ]');
+ assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ [Object] ] ] ]');
arr[0][0][0] = arr;
- assert.strictEqual(util.inspect(arr), '[ [ [ [Circular] ] ] ]');
+ assert.strictEqual(util.inspect(arr, { depth: 2 }), '[ [ [ [Circular] ] ] ]');
}
// Corner cases.
@@ -1117,22 +1117,22 @@ if (typeof Symbol !== 'undefined') {
assert(!/1 more item/.test(util.inspect(arr)));
util.inspect.defaultOptions.maxArrayLength = oldOptions.maxArrayLength;
assert(/1 more item/.test(util.inspect(arr)));
- util.inspect.defaultOptions.depth = null;
- assert(!/Object/.test(util.inspect(obj)));
- util.inspect.defaultOptions.depth = oldOptions.depth;
+ util.inspect.defaultOptions.depth = 2;
assert(/Object/.test(util.inspect(obj)));
+ util.inspect.defaultOptions.depth = oldOptions.depth;
+ assert(!/Object/.test(util.inspect(obj)));
assert.strictEqual(
JSON.stringify(util.inspect.defaultOptions),
JSON.stringify(oldOptions)
);
// Set multiple options through object assignment
- util.inspect.defaultOptions = { maxArrayLength: null, depth: null };
+ util.inspect.defaultOptions = { maxArrayLength: null, depth: 2 };
assert(!/1 more item/.test(util.inspect(arr)));
- assert(!/Object/.test(util.inspect(obj)));
+ assert(/Object/.test(util.inspect(obj)));
util.inspect.defaultOptions = oldOptions;
assert(/1 more item/.test(util.inspect(arr)));
- assert(/Object/.test(util.inspect(obj)));
+ assert(!/Object/.test(util.inspect(obj)));
assert.strictEqual(
JSON.stringify(util.inspect.defaultOptions),
JSON.stringify(oldOptions)