Skip to content

Commit 28d009b

Browse files
Tobias KahseFishrock123
authored andcommitted
test: refactored test-crypto-random.js
Replaced `var` by `const` for constant variables, enforced strict equality check, and replaced custom callback execution check by `common.mustCall`. PR-URL: #8632 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
1 parent a89deb9 commit 28d009b

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

test/parallel/test-crypto-random.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
2+
const common = require('../common');
3+
const assert = require('assert');
44

55
if (!common.hasCrypto) {
66
common.skip('missing crypto');
77
return;
88
}
9-
var crypto = require('crypto');
9+
const crypto = require('crypto');
1010

1111
crypto.DEFAULT_ENCODING = 'buffer';
1212

@@ -29,27 +29,14 @@ process.setMaxListeners(256);
2929
});
3030

3131
[0, 1, 2, 4, 16, 256, 1024].forEach(function(len) {
32-
f(len, checkCall(function(ex, buf) {
33-
assert.equal(null, ex);
34-
assert.equal(len, buf.length);
32+
f(len, common.mustCall(function(ex, buf) {
33+
assert.strictEqual(null, ex);
34+
assert.strictEqual(len, buf.length);
3535
assert.ok(Buffer.isBuffer(buf));
3636
}));
3737
});
3838
});
3939

40-
// assert that the callback is indeed called
41-
function checkCall(cb, desc) {
42-
var called_ = false;
43-
44-
process.on('exit', function() {
45-
assert.equal(true, called_, desc || ('callback not called: ' + cb));
46-
});
47-
48-
return function() {
49-
return called_ = true, cb.apply(cb, Array.prototype.slice.call(arguments));
50-
};
51-
}
52-
5340
// #5126, "FATAL ERROR: v8::Object::SetIndexedPropertiesToExternalArrayData()
5441
// length exceeds max acceptable value"
5542
assert.throws(function() {

0 commit comments

Comments
 (0)