Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-02-28 10:56:39 +0300
committerAnna Henningsen <anna@addaleax.net>2017-03-06 01:24:29 +0300
commit1445e282c3f42069faf2f9b6469a25808cb72c76 (patch)
tree3e81f2c98f86a8b012d15f60a742f51a007fa564 /test
parent3e79dffd2c0b11f9cd5f2b2b56557c858fe1ad43 (diff)
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-buffer-prototype-inspect.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-prototype-inspect.js b/test/parallel/test-buffer-prototype-inspect.js
new file mode 100644
index 00000000000..5f65a9bb288
--- /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), '<Buffer 66 68 71 77 68 67 61 64 73>');
+}
+
+{
+ const buf = Buffer.from('');
+ assert.strictEqual(util.inspect(buf), '<Buffer >');
+}
+
+{
+ const buf = Buffer.from('x'.repeat(51));
+ assert.ok(/^<Buffer (78 ){50}\.\.\. >$/.test(util.inspect(buf)));
+}