mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix(ext/node): correct kMaxLength
value of node:buffer
(#29504)
This commit is contained in:
parent
b27f88239d
commit
4a80e1d29b
3 changed files with 10 additions and 9 deletions
|
@ -113,7 +113,7 @@ float32Array[0] = -1; // 0xBF800000
|
||||||
// check this with `os.endianness()` because that is determined at compile time.
|
// check this with `os.endianness()` because that is determined at compile time.
|
||||||
export const bigEndian = uInt8Float32Array[3] === 0;
|
export const bigEndian = uInt8Float32Array[3] === 0;
|
||||||
|
|
||||||
export const kMaxLength = 2147483647;
|
export const kMaxLength = NumberMAX_SAFE_INTEGER;
|
||||||
export const kStringMaxLength = 536870888;
|
export const kStringMaxLength = 536870888;
|
||||||
const MAX_UINT32 = 2 ** 32;
|
const MAX_UINT32 = 2 ** 32;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
"test-assert-fail.js",
|
"test-assert-fail.js",
|
||||||
"test-assert.js",
|
"test-assert.js",
|
||||||
"test-blocklist.js",
|
"test-blocklist.js",
|
||||||
"test-buffer-alloc.js",
|
|
||||||
"test-buffer-arraybuffer.js",
|
"test-buffer-arraybuffer.js",
|
||||||
"test-buffer-backing-arraybuffer.js",
|
"test-buffer-backing-arraybuffer.js",
|
||||||
"test-buffer-includes.js",
|
"test-buffer-includes.js",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// deno-lint-ignore-file
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
// Taken from Node 18.12.1
|
// Taken from Node 23.9.0
|
||||||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -11,13 +11,16 @@ const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
|
|
||||||
const SlowBuffer = require('buffer').SlowBuffer;
|
const {
|
||||||
|
SlowBuffer,
|
||||||
|
kMaxLength,
|
||||||
|
} = require('buffer');
|
||||||
|
|
||||||
// Verify the maximum Uint8Array size.
|
// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
|
||||||
// (see https://github.com/tc39/ecma262/pull/3052).
|
// internal limits should be updated if this fails.
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => new Uint8Array(2 ** 53),
|
() => new Uint8Array(kMaxLength + 1),
|
||||||
{ message: 'Invalid typed array length: 9007199254740992' }
|
{ message: `Invalid typed array length: ${kMaxLength + 1}` },
|
||||||
);
|
);
|
||||||
|
|
||||||
const b = Buffer.allocUnsafe(1024);
|
const b = Buffer.allocUnsafe(1024);
|
||||||
|
@ -1154,7 +1157,6 @@ assert.throws(() => {
|
||||||
// Regression test to verify that an empty ArrayBuffer does not throw.
|
// Regression test to verify that an empty ArrayBuffer does not throw.
|
||||||
Buffer.from(new ArrayBuffer());
|
Buffer.from(new ArrayBuffer());
|
||||||
|
|
||||||
|
|
||||||
// Test that ArrayBuffer from a different context is detected correctly.
|
// Test that ArrayBuffer from a different context is detected correctly.
|
||||||
const arrayBuf = vm.runInNewContext('new ArrayBuffer()');
|
const arrayBuf = vm.runInNewContext('new ArrayBuffer()');
|
||||||
Buffer.from(arrayBuf);
|
Buffer.from(arrayBuf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue