From d6a4e3def993f781b8ee5695a159657705bc9b01 Mon Sep 17 00:00:00 2001 From: joyeecheung Date: Thu, 1 Dec 2016 10:33:24 -0600 Subject: [PATCH 1/3] test: fix test for buffer regression #649 - pass a regexp to assert.throws() --- test/parallel/test-buffer-regression-649.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-buffer-regression-649.js b/test/parallel/test-buffer-regression-649.js index b11e4a50e5d447..28681594fe2da3 100644 --- a/test/parallel/test-buffer-regression-649.js +++ b/test/parallel/test-buffer-regression-649.js @@ -6,8 +6,14 @@ const SlowBuffer = require('buffer').SlowBuffer; // Regression test for https://github.com/nodejs/node/issues/649. const len = 1422561062959; -assert.throws(() => Buffer(len).toString('utf8')); -assert.throws(() => SlowBuffer(len).toString('utf8')); -assert.throws(() => Buffer.alloc(len).toString('utf8')); -assert.throws(() => Buffer.allocUnsafe(len).toString('utf8')); -assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8')); +const lenLimitMsg = /^RangeError: Invalid typed array length$/; +assert.throws(() => Buffer(len).toString('utf8'), + lenLimitMsg); +assert.throws(() => SlowBuffer(len).toString('utf8'), + lenLimitMsg); +assert.throws(() => Buffer.alloc(len).toString('utf8'), + lenLimitMsg); +assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), + lenLimitMsg); +assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), + lenLimitMsg); From 1277c6a94a6a801c5ce22f03e1dfe898c3143095 Mon Sep 17 00:00:00 2001 From: joyeecheung Date: Mon, 5 Dec 2016 00:09:40 +0800 Subject: [PATCH 2/3] test: squash line for buffer regression #649 test --- test/parallel/test-buffer-regression-649.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-buffer-regression-649.js b/test/parallel/test-buffer-regression-649.js index 28681594fe2da3..5b1f09f8df2157 100644 --- a/test/parallel/test-buffer-regression-649.js +++ b/test/parallel/test-buffer-regression-649.js @@ -7,13 +7,9 @@ const SlowBuffer = require('buffer').SlowBuffer; // Regression test for https://github.com/nodejs/node/issues/649. const len = 1422561062959; const lenLimitMsg = /^RangeError: Invalid typed array length$/; -assert.throws(() => Buffer(len).toString('utf8'), - lenLimitMsg); -assert.throws(() => SlowBuffer(len).toString('utf8'), - lenLimitMsg); -assert.throws(() => Buffer.alloc(len).toString('utf8'), - lenLimitMsg); -assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), - lenLimitMsg); +assert.throws(() => Buffer(len).toString('utf8'), lenLimitMsg); +assert.throws(() => SlowBuffer(len).toString('utf8'), lenLimitMsg); +assert.throws(() => Buffer.alloc(len).toString('utf8'), lenLimitMsg); +assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), lenLimitMsg); assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), lenLimitMsg); From c67965469e3f9d9a124aa64e94bca16cf8297e5a Mon Sep 17 00:00:00 2001 From: joyeecheung Date: Tue, 6 Dec 2016 22:20:49 +0800 Subject: [PATCH 3/3] test: loose the error message regexp for platform differences --- test/parallel/test-buffer-regression-649.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-buffer-regression-649.js b/test/parallel/test-buffer-regression-649.js index 5b1f09f8df2157..ab7228e84c1c13 100644 --- a/test/parallel/test-buffer-regression-649.js +++ b/test/parallel/test-buffer-regression-649.js @@ -6,7 +6,10 @@ const SlowBuffer = require('buffer').SlowBuffer; // Regression test for https://github.com/nodejs/node/issues/649. const len = 1422561062959; -const lenLimitMsg = /^RangeError: Invalid typed array length$/; +const lenLimitMsg = new RegExp('^RangeError: (Invalid typed array length' + + '|Array buffer allocation failed' + + '|Invalid array buffer length)$'); + assert.throws(() => Buffer(len).toString('utf8'), lenLimitMsg); assert.throws(() => SlowBuffer(len).toString('utf8'), lenLimitMsg); assert.throws(() => Buffer.alloc(len).toString('utf8'), lenLimitMsg);