diff options
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-buffer-alloc.js')
-rw-r--r-- | cli/tests/node_compat/test/parallel/test-buffer-alloc.js | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-buffer-alloc.js b/cli/tests/node_compat/test/parallel/test-buffer-alloc.js index c93e80f63..35b29ae95 100644 --- a/cli/tests/node_compat/test/parallel/test-buffer-alloc.js +++ b/cli/tests/node_compat/test/parallel/test-buffer-alloc.js @@ -2,14 +2,14 @@ // deno-lint-ignore-file // Copyright Joyent and Node contributors. All rights reserved. MIT license. -// Taken from Node 16.13.0 -// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually +// Taken from Node 18.12.1 +// This file is automatically generated by `tools/node_compat/setup.ts`. Do not modify this file manually. 'use strict'; const common = require('../common'); const assert = require('assert'); -const vm = require('vm'); +// const vm = require('vm'); const SlowBuffer = require('buffer').SlowBuffer; @@ -48,7 +48,25 @@ assert.strictEqual(d.length, 0); assert.strictEqual(b.offset, 0); } +// Test creating a Buffer from a Uint8Array +{ + const ui8 = new Uint8Array(4).fill(42); + const e = Buffer.from(ui8); + for (const [index, value] of e.entries()) { + assert.strictEqual(value, ui8[index]); + } +} +// Test creating a Buffer from a Uint8Array (old constructor) +{ + const ui8 = new Uint8Array(4).fill(42); + const e = Buffer(ui8); + for (const [key, value] of e.entries()) { + assert.strictEqual(value, ui8[key]); + } +} + // Test creating a Buffer from a Uint32Array +// Note: it is implicitly interpreted as Array of integers modulo 256 { const ui32 = new Uint32Array(4).fill(42); const e = Buffer.from(ui32); @@ -57,11 +75,12 @@ assert.strictEqual(d.length, 0); } } // Test creating a Buffer from a Uint32Array (old constructor) +// Note: it is implicitly interpreted as Array of integers modulo 256 { const ui32 = new Uint32Array(4).fill(42); const e = Buffer(ui32); for (const [key, value] of e.entries()) { - assert.deepStrictEqual(value, ui32[key]); + assert.strictEqual(value, ui32[key]); } } |