diff options
author | Сковорода Никита Андреевич <chalkerx@gmail.com> | 2016-06-01 17:32:02 +0300 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-06-02 09:21:53 +0200 |
commit | fea3070ec46d8d231b95ff100170d16306814ee8 (patch) | |
tree | 84bc701d3b75fde478e8ae6596b7e83a6d5b5317 /test | |
parent | 3a3996315c39b377d19db03434acf27d1d83cb98 (diff) | |
download | android-node-v8-fea3070ec46d8d231b95ff100170d16306814ee8.tar.gz android-node-v8-fea3070ec46d8d231b95ff100170d16306814ee8.tar.bz2 android-node-v8-fea3070ec46d8d231b95ff100170d16306814ee8.zip |
test: add buffer testcase for resetting kZeroFill
Test failed or zero-sized Buffer allocations not affecting subsequent
creations of typed arrays.
PR-URL: https://github.com/nodejs/node/pull/7093
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-buffer.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-buffer.js b/test/parallel/test-buffer.js index 02f9443696..f773da321d 100644 --- a/test/parallel/test-buffer.js +++ b/test/parallel/test-buffer.js @@ -1476,3 +1476,26 @@ assert.equal(SlowBuffer.prototype.offset, undefined); // Check pool offset after that by trying to write string into the pool. assert.doesNotThrow(() => Buffer.from('abc')); } + + +// Test failed or zero-sized Buffer allocations not affecting typed arrays +{ + const zeroArray = new Uint32Array(10).fill(0); + const sizes = [1e10, 0, 0.1, -1, 'a', undefined, null, NaN]; + const allocators = [ + Buffer, + SlowBuffer, + Buffer.alloc, + Buffer.allocUnsafe, + Buffer.allocUnsafeSlow + ]; + for (const allocator of allocators) { + for (const size of sizes) { + try { + allocator(size); + } catch (e) { + assert.deepStrictEqual(new Uint32Array(10), zeroArray); + } + } + } +} |