diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2016-12-13 12:51:01 +0800 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-12-13 19:25:13 +0100 |
commit | 3d353c749cdb64b2d018766d05ba0e9b9b0f7ec8 (patch) | |
tree | 1e98fa2e1b0522361d26800da2d3757f058a7124 /test/parallel/test-buffer-slow.js | |
parent | 832960592faaf290903adcc768778ef4bdc6e9fc (diff) | |
download | android-node-v8-3d353c749cdb64b2d018766d05ba0e9b9b0f7ec8.tar.gz android-node-v8-3d353c749cdb64b2d018766d05ba0e9b9b0f7ec8.tar.bz2 android-node-v8-3d353c749cdb64b2d018766d05ba0e9b9b0f7ec8.zip |
buffer: consistent error for length > kMaxLength
- Always return the same error message(hopefully more informative)
for buffer length > kMaxLength and avoid getting into V8 C++ land
for unnecessary checks.
- Use accurate RegExp(reusable as `common.bufferMaxSizeMsg`)
in tests for this error.
- Separate related tests from test-buffer-alloc.
PR-URL: https://github.com/nodejs/node/pull/10152
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-buffer-slow.js')
-rw-r--r-- | test/parallel/test-buffer-slow.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/parallel/test-buffer-slow.js b/test/parallel/test-buffer-slow.js index 7d27a9be11..bb944ae4de 100644 --- a/test/parallel/test-buffer-slow.js +++ b/test/parallel/test-buffer-slow.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const buffer = require('buffer'); const Buffer = buffer.Buffer; @@ -51,10 +51,10 @@ assert.strictEqual(SlowBuffer('string').length, 0); // should throw with invalid length assert.throws(function() { SlowBuffer(Infinity); -}, /^RangeError: Invalid array buffer length$/); +}, common.bufferMaxSizeMsg); assert.throws(function() { SlowBuffer(-1); -}, /^RangeError: Invalid array buffer length$/); +}, /^RangeError: "size" argument must not be negative$/); assert.throws(function() { SlowBuffer(buffer.kMaxLength + 1); -}, /^RangeError: (Invalid typed array length|Array buffer allocation failed)$/); +}, common.bufferMaxSizeMsg); |