diff --git a/test/parallel/test-buffer-regression-649.js b/test/parallel/test-buffer-regression-649.js index b11e4a50e5d447..ab7228e84c1c13 100644 --- a/test/parallel/test-buffer-regression-649.js +++ b/test/parallel/test-buffer-regression-649.js @@ -6,8 +6,13 @@ 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 = 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); +assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), lenLimitMsg); +assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), + lenLimitMsg);