diff --git a/test/parallel/test-buffer-prototype-inspect.js b/test/parallel/test-buffer-prototype-inspect.js new file mode 100644 index 0000000000..5f65a9bb28 --- /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))); +}