xref: /third_party/node/test/parallel/test-buffer-parent-property.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Fix for https://github.com/nodejs/node/issues/8266
41cb0ef41Sopenharmony_ci//
51cb0ef41Sopenharmony_ci// Zero length Buffer objects should expose the `buffer` property of the
61cb0ef41Sopenharmony_ci// TypedArrays, via the `parent` property.
71cb0ef41Sopenharmony_cirequire('../common');
81cb0ef41Sopenharmony_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci// If the length of the buffer object is zero
111cb0ef41Sopenharmony_ciassert((new Buffer(0)).parent instanceof ArrayBuffer);
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci// If the length of the buffer object is equal to the underlying ArrayBuffer
141cb0ef41Sopenharmony_ciassert((new Buffer(Buffer.poolSize)).parent instanceof ArrayBuffer);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// Same as the previous test, but with user created buffer
171cb0ef41Sopenharmony_ciconst arrayBuffer = new ArrayBuffer(0);
181cb0ef41Sopenharmony_ciassert.strictEqual(new Buffer(arrayBuffer).parent, arrayBuffer);
191cb0ef41Sopenharmony_ciassert.strictEqual(new Buffer(arrayBuffer).buffer, arrayBuffer);
201cb0ef41Sopenharmony_ciassert.strictEqual(Buffer.from(arrayBuffer).parent, arrayBuffer);
211cb0ef41Sopenharmony_ciassert.strictEqual(Buffer.from(arrayBuffer).buffer, arrayBuffer);
22

Indexes created Thu Nov 07 10:32:03 CST 2024