1'use strict'; 2 3/* 4 * Fix for https://github.com/nodejs/node/issues/8266 5 * 6 * Zero length Buffer objects should expose the `buffer` property of the 7 * TypedArrays, via the `parent` property. 8 */ 9require('../common'); 10const assert = require('assert'); 11 12// If the length of the buffer object is zero 13assert((new Buffer(0)).parent instanceof ArrayBuffer); 14 15// If the length of the buffer object is equal to the underlying ArrayBuffer 16assert((new Buffer(Buffer.poolSize)).parent instanceof ArrayBuffer); 17 18// Same as the previous test, but with user created buffer 19const arrayBuffer = new ArrayBuffer(0); 20assert.strictEqual(new Buffer(arrayBuffer).parent, arrayBuffer); 21assert.strictEqual(new Buffer(arrayBuffer).buffer, arrayBuffer); 22assert.strictEqual(Buffer.from(arrayBuffer).parent, arrayBuffer); 23assert.strictEqual(Buffer.from(arrayBuffer).buffer, arrayBuffer); 24