Skip to content

Commit cd1a7ea

Browse files
NFoxleyMylesBorins
authored andcommitted
test: add regex to text-crypto-random
PR-URL: #10020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 15226f5 commit cd1a7ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/parallel/test-crypto-random.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ crypto.DEFAULT_ENCODING = 'buffer';
1313
// bump, we register a lot of exit listeners
1414
process.setMaxListeners(256);
1515

16+
const expectedErrorRegexp = /^TypeError: size must be a number >= 0$/;
1617
[crypto.randomBytes, crypto.pseudoRandomBytes].forEach(function(f) {
1718
[-1, undefined, null, false, true, {}, []].forEach(function(value) {
18-
assert.throws(function() { f(value); }, TypeError);
19-
assert.throws(function() { f(value, function() {}); }, TypeError);
19+
assert.throws(function() { f(value); }, expectedErrorRegexp);
20+
assert.throws(function() { f(value, function() {}); }, expectedErrorRegexp);
2021
});
2122

2223
[0, 1, 2, 4, 16, 256, 1024].forEach(function(len) {

0 commit comments

Comments
 (0)