| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 696d859 commit 62bfc75
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,37 +1,28 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | ||
| 5 | 4 | if (!common.hasCrypto) { | |
| 6 | 5 | common.skip('missing crypto'); | |
| 7 | 6 | return; | |
| 8 | 7 | } | |
| 8 | + const assert = require('assert'); | ||
| 9 | 9 | const crypto = require('crypto'); | |
| 10 | 10 | ||
| 11 | 11 | crypto.DEFAULT_ENCODING = 'buffer'; | |
| 12 | 12 | ||
| 13 | 13 | // bump, we register a lot of exit listeners | |
| 14 | 14 | process.setMaxListeners(256); | |
| 15 | 15 | ||
| 16 | - [crypto.randomBytes, | ||
| 17 | - crypto.pseudoRandomBytes | ||
| 18 | - ].forEach(function(f) { | ||
| 19 | - [-1, | ||
| 20 | - undefined, | ||
| 21 | - null, | ||
| 22 | - false, | ||
| 23 | - true, | ||
| 24 | - {}, | ||
| 25 | - [] | ||
| 26 | - ].forEach(function(value) { | ||
| 27 | - assert.throws(function() { f(value); }); | ||
| 28 | - assert.throws(function() { f(value, function() {}); }); | ||
| 16 | + [crypto.randomBytes, crypto.pseudoRandomBytes].forEach(function(f) { | ||
| 17 | + [-1, undefined, null, false, true, {}, []].forEach(function(value) { | ||
| 18 | + assert.throws(function() { f(value); }, TypeError); | ||
| 19 | + assert.throws(function() { f(value, function() {}); }, TypeError); | ||
| 29 | 20 | }); | |
| 30 | 21 | ||
| 31 | 22 | [0, 1, 2, 4, 16, 256, 1024].forEach(function(len) { | |
| 32 | 23 | f(len, common.mustCall(function(ex, buf) { | |
| 33 | - assert.strictEqual(null, ex); | ||
| 34 | - assert.strictEqual(len, buf.length); | ||
| 24 | + assert.strictEqual(ex, null); | ||
| 25 | + assert.strictEqual(buf.length, len); | ||
| 35 | 26 | assert.ok(Buffer.isBuffer(buf)); | |
| 36 | 27 | })); | |
| 37 | 28 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments