Skip to content
Permalink
Browse files

test,benchmark: use deepStrictEqual()

In preparation for a lint rule that will enforce
assert.deepStrictEqual() over assert.deepEqual(), change tests and
benchmarks accordingly. For tests and benchmarks that are testing or
benchmarking assert.deepEqual() itself, apply a comment to ignore the
upcoming rule.

PR-URL: #6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
Trott committed Apr 19, 2016
1 parent 5eb4ec0 commit a7335bd1f048f6592f609eec0c87c007e98d754c
Showing with 474 additions and 378 deletions.
  1. +1 −0 benchmark/assert/deepequal-prims-and-objs-big-array.js
  2. +1 −0 benchmark/assert/deepequal-prims-and-objs-big-loop.js
  3. +1 −0 benchmark/assert/deepequal-typedarrays.js
  4. +1 −0 test/parallel/test-assert-typedarray-deepequal.js
  5. +1 −0 test/parallel/test-assert.js
  6. +36 −34 test/parallel/test-buffer-alloc.js
  7. +17 −10 test/parallel/test-buffer-fill.js
  8. +5 −5 test/parallel/test-buffer-iterator.js
  9. +6 −2 test/parallel/test-buffer-slow.js
  10. +35 −32 test/parallel/test-buffer.js
  11. +1 −1 test/parallel/test-child-process-fork-exec-argv.js
  12. +1 −1 test/parallel/test-child-process-fork-exec-path.js
  13. +1 −1 test/parallel/test-child-process-fork-ref.js
  14. +1 −1 test/parallel/test-child-process-fork.js
  15. +2 −2 test/parallel/test-child-process-internal.js
  16. +1 −1 test/parallel/test-child-process-spawn-error.js
  17. +4 −4 test/parallel/test-child-process-spawnsync-input.js
  18. +1 −1 test/parallel/test-child-process-spawnsync-maxbuf.js
  19. +1 −1 test/parallel/test-child-process-spawnsync.js
  20. +1 −1 test/parallel/test-child-process-stdio.js
  21. +1 −1 test/parallel/test-cluster-basic.js
  22. +1 −1 test/parallel/test-cluster-disconnect-idle-worker.js
  23. +10 −7 test/parallel/test-cluster-setup-master-cumulative.js
  24. +1 −1 test/parallel/test-cluster-worker-events.js
  25. +1 −1 test/parallel/test-common.js
  26. +5 −3 test/parallel/test-crypto-binary-default.js
  27. +4 −4 test/parallel/test-crypto-dh.js
  28. +8 −6 test/parallel/test-crypto-hash.js
  29. +1 −1 test/parallel/test-crypto.js
  30. +6 −6 test/parallel/test-dns.js
  31. +10 −10 test/parallel/test-domain-enter-exit.js
  32. +2 −2 test/parallel/test-domain-safe-exit.js
  33. +6 −6 test/parallel/test-event-emitter-add-listeners.js
  34. +2 −1 test/parallel/test-event-emitter-listeners-side-effects.js
  35. +9 −9 test/parallel/test-event-emitter-listeners.js
  36. +9 −7 test/parallel/test-event-emitter-modify-in-emit.js
  37. +1 −1 test/parallel/test-event-emitter-num-args.js
  38. +9 −9 test/parallel/test-event-emitter-remove-all-listeners.js
  39. +10 −10 test/parallel/test-event-emitter-remove-listeners.js
  40. +3 −2 test/parallel/test-event-emitter-set-max-listeners-side-effects.js
  41. +2 −1 test/parallel/test-event-emitter-subclass.js
  42. +4 −4 test/parallel/test-event-emitter-symbols.js
  43. +2 −2 test/parallel/test-fs-read-buffer-zero-length.js
  44. +2 −2 test/parallel/test-fs-read-buffer.js
  45. +2 −2 test/parallel/test-fs-readdir.js
  46. +1 −1 test/parallel/test-fs-write-buffer.js
  47. +1 −1 test/parallel/test-http-agent-keepalive.js
  48. +1 −1 test/parallel/test-http-blank-header.js
  49. +7 −7 test/parallel/test-http-content-length.js
  50. +1 −1 test/parallel/test-http-methods.js
  51. +2 −2 test/parallel/test-http-mutable-headers.js
  52. +10 −7 test/parallel/test-http-parser.js
  53. +2 −2 test/parallel/test-http-proxy.js
  54. +8 −8 test/parallel/test-http-raw-headers.js
  55. +1 −1 test/parallel/test-http-remove-header-stays-removed.js
  56. +2 −2 test/parallel/test-http-set-cookies.js
  57. +1 −1 test/parallel/test-http-upgrade-agent.js
  58. +1 −1 test/parallel/test-http-upgrade-client.js
  59. +2 −2 test/parallel/test-net-server-max-connections-close-makes-more-available.js
  60. +2 −2 test/parallel/test-net-socket-local-address.js
  61. +1 −1 test/parallel/test-next-tick-errors.js
  62. +1 −1 test/parallel/test-next-tick-ordering2.js
  63. +2 −2 test/parallel/test-os.js
  64. +2 −2 test/parallel/test-path.js
  65. +1 −1 test/parallel/test-process-config.js
  66. +1 −1 test/parallel/test-process-exec-argv.js
  67. +6 −3 test/parallel/test-process-versions.js
  68. +1 −1 test/parallel/test-promises-unhandled-rejections.js
  69. +4 −4 test/parallel/test-querystring-escape.js
  70. +14 −16 test/parallel/test-querystring-multichar-separator.js
  71. +48 −15 test/parallel/test-querystring.js
  72. +1 −1 test/parallel/test-readline-interface.js
  73. +1 −1 test/parallel/test-readline-set-raw-mode.js
  74. +1 −1 test/parallel/test-regress-GH-2245.js
  75. +2 −2 test/parallel/test-repl-.save.load.js
  76. +9 −9 test/parallel/test-repl-tab-complete.js
  77. +1 −1 test/parallel/test-stdout-close-catch.js
  78. +2 −2 test/parallel/test-stream-push-order.js
  79. +1 −1 test/parallel/test-stream-push-strings.js
  80. +1 −1 test/parallel/test-stream-transform-objectmode-falsey-value.js
  81. +1 −1 test/parallel/test-stream-unshift-empty-chunk.js
  82. +1 −1 test/parallel/test-stream-writev.js
  83. +14 −14 test/parallel/test-stream2-objects.js
  84. +1 −1 test/parallel/test-stream2-push.js
  85. +2 −2 test/parallel/test-stream2-readable-empty-buffer-no-eof.js
  86. +1 −1 test/parallel/test-stream2-readable-wrap.js
  87. +2 −2 test/parallel/test-timers-args.js
  88. +1 −1 test/parallel/test-timers-immediate.js
  89. +1 −1 test/parallel/test-tls-multi-key.js
  90. +2 −2 test/parallel/test-tls-parse-cert-string.js
  91. +4 −2 test/parallel/test-tls-peer-certificate-multi-keys.js
  92. +1 −1 test/parallel/test-tls-peer-certificate.js
  93. +6 −4 test/parallel/test-tls-sni-option.js
  94. +2 −2 test/parallel/test-tls-sni-server-client.js
  95. +38 −17 test/parallel/test-url.js
  96. +1 −1 test/parallel/test-util-internal.js
  97. +7 −7 test/parallel/test-util.js
  98. +2 −2 test/parallel/test-v8-stats.js
  99. +2 −2 test/parallel/test-vm-basic.js
  100. +2 −1 test/parallel/test-vm-create-context-accessors.js
  101. +1 −1 test/parallel/test-vm-global-define-property.js
  102. +2 −2 test/parallel/test-zlib-flush.js
  103. +1 −1 test/parallel/test-zlib-invalid-input.js
  104. +1 −1 test/parallel/test-zlib-params.js
  105. +1 −1 test/pummel/test-crypto-dh.js
  106. +1 −1 test/pummel/test-dh-regr.js
  107. +2 −2 test/sequential/test-child-process-execsync.js
  108. +2 −2 test/sequential/test-module-loading.js
  109. +1 −1 test/sequential/test-stream2-fs.js
@@ -1,3 +1,4 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
@@ -1,3 +1,4 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
@@ -1,3 +1,4 @@
/* eslint no-deepEqual: 0 */
'use strict';
var common = require('../common.js');
var assert = require('assert');
@@ -1,3 +1,4 @@
/* eslint no-deepEqual: 0 */
'use strict';

require('../common');
@@ -1,3 +1,4 @@
/* eslint no-deepEqual: 0 */
'use strict';
require('../common');
var assert = require('assert');
@@ -32,7 +32,9 @@ assert.strictEqual(0, d.length);

var ui32 = new Uint32Array(4).fill(42);
var e = Buffer.from(ui32);
assert.deepEqual(ui32, e);
for (const [index, value] of e.entries()) {
assert.strictEqual(value, ui32[index]);
}

// First check Buffer#fill() works as expected.

@@ -463,32 +465,32 @@ for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
assert.equal(d[0], 23);
assert.equal(d[1], 42);
assert.equal(d[2], 255);
assert.deepEqual(d, Buffer.from(d));
assert.deepStrictEqual(d, Buffer.from(d));
}

{
const e = Buffer.from('über');
console.error('uber: \'%s\'', e.toString());
assert.deepEqual(e, Buffer.from([195, 188, 98, 101, 114]));
assert.deepStrictEqual(e, Buffer.from([195, 188, 98, 101, 114]));
}

{
const f = Buffer.from('über', 'ascii');
console.error('f.length: %d (should be 4)', f.length);
assert.deepEqual(f, Buffer.from([252, 98, 101, 114]));
assert.deepStrictEqual(f, Buffer.from([252, 98, 101, 114]));
}

['ucs2', 'ucs-2', 'utf16le', 'utf-16le'].forEach(function(encoding) {
{
const f = Buffer.from('über', encoding);
console.error('f.length: %d (should be 8)', f.length);
assert.deepEqual(f, Buffer.from([252, 0, 98, 0, 101, 0, 114, 0]));
assert.deepStrictEqual(f, Buffer.from([252, 0, 98, 0, 101, 0, 114, 0]));
}

{
const f = Buffer.from('привет', encoding);
console.error('f.length: %d (should be 12)', f.length);
assert.deepEqual(f,
assert.deepStrictEqual(f,
Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]));
assert.equal(f.toString(encoding), 'привет');
}
@@ -499,23 +501,23 @@ for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
const size = f.write('あいうえお', encoding);
console.error('bytes written to buffer: %d (should be 4)', size);
assert.equal(size, 4);
assert.deepEqual(f, Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00]));
assert.deepStrictEqual(f, Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00]));
}
});

{
const f = Buffer.from('\uD83D\uDC4D', 'utf-16le'); // THUMBS UP SIGN (U+1F44D)
assert.equal(f.length, 4);
assert.deepEqual(f, Buffer.from('3DD84DDC', 'hex'));
assert.deepStrictEqual(f, Buffer.from('3DD84DDC', 'hex'));
}


var arrayIsh = {0: 0, 1: 1, 2: 2, 3: 3, length: 4};
var g = Buffer.from(arrayIsh);
assert.deepEqual(g, Buffer.from([0, 1, 2, 3]));
assert.deepStrictEqual(g, Buffer.from([0, 1, 2, 3]));
var strArrayIsh = {0: '0', 1: '1', 2: '2', 3: '3', length: 4};
g = Buffer.from(strArrayIsh);
assert.deepEqual(g, Buffer.from([0, 1, 2, 3]));
assert.deepStrictEqual(g, Buffer.from([0, 1, 2, 3]));


//
@@ -526,10 +528,10 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64'));
{
// test that regular and URL-safe base64 both work
const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff];
assert.deepEqual(Buffer.from('//++/++/++//', 'base64'),
Buffer.from(expected));
assert.deepEqual(Buffer.from('__--_--_--__', 'base64'),
Buffer.from(expected));
assert.deepStrictEqual(Buffer.from('//++/++/++//', 'base64'),
Buffer.from(expected));
assert.deepStrictEqual(Buffer.from('__--_--_--__', 'base64'),
Buffer.from(expected));
}

{
@@ -1021,7 +1023,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);

assert.equal(string, '{"type":"Buffer","data":[116,101,115,116]}');

assert.deepEqual(buffer, JSON.parse(string, function(key, value) {
assert.deepStrictEqual(buffer, JSON.parse(string, function(key, value) {
return value && value.type === 'Buffer'
? Buffer.from(value.data)
: value;
@@ -1167,92 +1169,92 @@ assert.throws(function() {
(function() {
var buf = Buffer.allocUnsafe(3);
buf.writeUIntLE(0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]);
assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]);
assert.equal(buf.readUIntLE(0, 3), 0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeUIntBE(0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]);
assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]);
assert.equal(buf.readUIntBE(0, 3), 0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeIntLE(0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x56, 0x34, 0x12]);
assert.deepStrictEqual(buf.toJSON().data, [0x56, 0x34, 0x12]);
assert.equal(buf.readIntLE(0, 3), 0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeIntBE(0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56]);
assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56]);
assert.equal(buf.readIntBE(0, 3), 0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeIntLE(-0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]);
assert.deepStrictEqual(buf.toJSON().data, [0xaa, 0xcb, 0xed]);
assert.equal(buf.readIntLE(0, 3), -0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeIntBE(-0x123456, 0, 3);
assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]);
assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xaa]);
assert.equal(buf.readIntBE(0, 3), -0x123456);

buf = Buffer.allocUnsafe(3);
buf.writeIntLE(-0x123400, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]);
assert.deepStrictEqual(buf.toJSON().data, [0x00, 0xcc, 0xed]);
assert.equal(buf.readIntLE(0, 3), -0x123400);

buf = Buffer.allocUnsafe(3);
buf.writeIntBE(-0x123400, 0, 3);
assert.deepEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]);
assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcc, 0x00]);
assert.equal(buf.readIntBE(0, 3), -0x123400);

buf = Buffer.allocUnsafe(3);
buf.writeIntLE(-0x120000, 0, 3);
assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0xee]);
assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0xee]);
assert.equal(buf.readIntLE(0, 3), -0x120000);

buf = Buffer.allocUnsafe(3);
buf.writeIntBE(-0x120000, 0, 3);
assert.deepEqual(buf.toJSON().data, [0xee, 0x00, 0x00]);
assert.deepStrictEqual(buf.toJSON().data, [0xee, 0x00, 0x00]);
assert.equal(buf.readIntBE(0, 3), -0x120000);

buf = Buffer.allocUnsafe(5);
buf.writeUIntLE(0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]);
assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]);
assert.equal(buf.readUIntLE(0, 5), 0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeUIntBE(0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]);
assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]);
assert.equal(buf.readUIntBE(0, 5), 0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeIntLE(0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]);
assert.deepStrictEqual(buf.toJSON().data, [0x90, 0x78, 0x56, 0x34, 0x12]);
assert.equal(buf.readIntLE(0, 5), 0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeIntBE(0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]);
assert.deepStrictEqual(buf.toJSON().data, [0x12, 0x34, 0x56, 0x78, 0x90]);
assert.equal(buf.readIntBE(0, 5), 0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeIntLE(-0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]);
assert.deepStrictEqual(buf.toJSON().data, [0x70, 0x87, 0xa9, 0xcb, 0xed]);
assert.equal(buf.readIntLE(0, 5), -0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeIntBE(-0x1234567890, 0, 5);
assert.deepEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]);
assert.deepStrictEqual(buf.toJSON().data, [0xed, 0xcb, 0xa9, 0x87, 0x70]);
assert.equal(buf.readIntBE(0, 5), -0x1234567890);

buf = Buffer.allocUnsafe(5);
buf.writeIntLE(-0x0012000000, 0, 5);
assert.deepEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]);
assert.deepStrictEqual(buf.toJSON().data, [0x00, 0x00, 0x00, 0xee, 0xff]);
assert.equal(buf.readIntLE(0, 5), -0x0012000000);

buf = Buffer.allocUnsafe(5);
buf.writeIntBE(-0x0012000000, 0, 5);
assert.deepEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]);
assert.deepStrictEqual(buf.toJSON().data, [0xff, 0xee, 0x00, 0x00, 0x00]);
assert.equal(buf.readIntBE(0, 5), -0x0012000000);
})();

@@ -1292,7 +1294,7 @@ assert.throws(function() {
}

var utf16Buf = Buffer.from('0123456789', 'utf16le');
assert.deepEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));
assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le'));

assert.equal(buf.slice('0', '1'), '0');
assert.equal(buf.slice('-5', '10'), '56789');
@@ -140,18 +140,25 @@ testBufs('Yci0Ysi1Y8i2', 12, 1, 'ucs2');


// Buffer
function deepStrictEqualValues(buf, arr) {
for (const [index, value] of buf.entries()) {
assert.deepStrictEqual(value, arr[index]);
}
}


const buf2Fill = Buffer.allocUnsafe(1).fill(2);
assert.deepEqual(genBuffer(4, [buf2Fill]), [2, 2, 2, 2]);
assert.deepEqual(genBuffer(4, [buf2Fill, 1]), [0, 2, 2, 2]);
assert.deepEqual(genBuffer(4, [buf2Fill, 1, 3]), [0, 2, 2, 0]);
assert.deepEqual(genBuffer(4, [buf2Fill, 1, 1]), [0, 0, 0, 0]);
assert.deepEqual(genBuffer(4, [buf2Fill, 1, -1]), [0, 0, 0, 0]);
deepStrictEqualValues(genBuffer(4, [buf2Fill]), [2, 2, 2, 2]);
deepStrictEqualValues(genBuffer(4, [buf2Fill, 1]), [0, 2, 2, 2]);
deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 3]), [0, 2, 2, 0]);
deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 1]), [0, 0, 0, 0]);
deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, -1]), [0, 0, 0, 0]);
const hexBufFill = Buffer.allocUnsafe(2).fill(0).fill('0102', 'hex');
assert.deepEqual(genBuffer(4, [hexBufFill]), [1, 2, 1, 2]);
assert.deepEqual(genBuffer(4, [hexBufFill, 1]), [0, 1, 2, 1]);
assert.deepEqual(genBuffer(4, [hexBufFill, 1, 3]), [0, 1, 2, 0]);
assert.deepEqual(genBuffer(4, [hexBufFill, 1, 1]), [0, 0, 0, 0]);
assert.deepEqual(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);
deepStrictEqualValues(genBuffer(4, [hexBufFill]), [1, 2, 1, 2]);
deepStrictEqualValues(genBuffer(4, [hexBufFill, 1]), [0, 1, 2, 1]);
deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 3]), [0, 1, 2, 0]);
deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 1]), [0, 0, 0, 0]);
deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]);


// Check exceptions
@@ -13,7 +13,7 @@ arr = [];
for (b of buffer)
arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);


// buffer iterators should be iterable
@@ -23,7 +23,7 @@ arr = [];
for (b of buffer[Symbol.iterator]())
arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);


// buffer#values() should return iterator for values
@@ -33,7 +33,7 @@ arr = [];
for (b of buffer.values())
arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);


// buffer#keys() should return iterator for keys
@@ -43,7 +43,7 @@ arr = [];
for (b of buffer.keys())
arr.push(b);

assert.deepEqual(arr, [0, 1, 2, 3, 4]);
assert.deepStrictEqual(arr, [0, 1, 2, 3, 4]);


// buffer#entries() should return iterator for entries
@@ -53,7 +53,7 @@ arr = [];
for (b of buffer.entries())
arr.push(b);

assert.deepEqual(arr, [
assert.deepStrictEqual(arr, [
[0, 1],
[1, 2],
[2, 3],
@@ -13,7 +13,9 @@ let sb = SlowBuffer(4);
assert(sb instanceof Buffer);
assert.strictEqual(sb.length, 4);
sb.fill(1);
assert.deepEqual(sb, ones);
for (const [key, value] of sb.entries()) {
assert.deepStrictEqual(value, ones[key]);
}

// underlying ArrayBuffer should have the same length
assert.strictEqual(sb.buffer.byteLength, 4);
@@ -23,7 +25,9 @@ sb = SlowBuffer(4);
assert(sb instanceof Buffer);
assert.strictEqual(sb.length, 4);
sb.fill(1);
assert.deepEqual(sb, ones);
for (const [key, value] of sb.entries()) {
assert.deepStrictEqual(value, ones[key]);
}

// should work with edge cases
assert.strictEqual(SlowBuffer(0).length, 0);

0 comments on commit a7335bd

Please sign in to comment.
You can’t perform that action at this time.