From effb5e1ce417e9b7f22adcdc598e9a5ec593f4a2 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sun, 8 Oct 2023 11:09:50 +0900 Subject: fix(node/buffer): utf8ToBytes should return a Uint8Array (#20769) --- .../test/parallel/test-buffer-arraybuffer.js | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js') diff --git a/cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js b/cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js index 9f515736e..286481758 100644 --- a/cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js +++ b/cli/tests/node_compat/test/parallel/test-buffer-arraybuffer.js @@ -2,8 +2,8 @@ // 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'; @@ -42,21 +42,18 @@ assert.strictEqual(dv.getFloat64(8, true), 3.1415); // Now test protecting users from doing stupid things -// TODO(Soremwar) -// There is an inconsistency on feross implementation on how buffers are checked -// Enable once it's sorted out -// assert.throws(function() { -// function AB() { } -// Object.setPrototypeOf(AB, ArrayBuffer); -// Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); -// Buffer.from(new AB()); -// }, { -// code: 'ERR_INVALID_ARG_TYPE', -// name: 'TypeError', -// message: 'The first argument must be of type string or an instance of ' + -// 'Buffer, ArrayBuffer, or Array or an Array-like Object. Received ' + -// 'an instance of AB' -// }); +assert.throws(function() { + function AB() { } + Object.setPrototypeOf(AB, ArrayBuffer); + Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); + Buffer.from(new AB()); +}, { + code: 'ERR_INVALID_ARG_TYPE', + name: 'TypeError', + message: 'The first argument must be of type string or an instance of ' + + 'Buffer, ArrayBuffer, or Array or an Array-like Object. Received ' + + 'an instance of AB' +}); // Test the byteOffset and length arguments { -- cgit v1.2.3