From 1445e282c3f42069faf2f9b6469a25808cb72c76 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 27 Feb 2017 23:56:39 -0800 Subject: [PATCH] test: add test-buffer-prototype-inspect lib/buffer.js defines Buffer.prototype.inspect() to override how buffers are presented by util.inspect(). Add basic tests for it. PR-URL: https://github.com/nodejs/node/pull/11600 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Yuta Hiroto Reviewed-By: Luigi Pinca --- .../parallel/test-buffer-prototype-inspect.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-buffer-prototype-inspect.js diff --git a/test/parallel/test-buffer-prototype-inspect.js b/test/parallel/test-buffer-prototype-inspect.js new file mode 100644 index 00000000000000..5f65a9bb288f16 --- /dev/null +++ b/test/parallel/test-buffer-prototype-inspect.js @@ -0,0 +1,23 @@ +'use strict'; +require('../common'); + +// lib/buffer.js defines Buffer.prototype.inspect() to override how buffers are +// presented by util.inspect(). + +const assert = require('assert'); +const util = require('util'); + +{ + const buf = Buffer.from('fhqwhgads'); + assert.strictEqual(util.inspect(buf), ''); +} + +{ + const buf = Buffer.from(''); + assert.strictEqual(util.inspect(buf), ''); +} + +{ + const buf = Buffer.from('x'.repeat(51)); + assert.ok(/^$/.test(util.inspect(buf))); +}