Skip to content

Commit

Permalink
test: refactor test-fs-non-number-arguments-throw
Browse files Browse the repository at this point in the history
* Add RegExp arguments to throws assertions.
* Use common.mustCall for emitter callback.

PR-URL: #9844
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
targos authored and MylesBorins committed Dec 21, 2016
1 parent b5218d2 commit 11461ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/parallel/test-fs-non-number-arguments-throw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 });

assert.throws(function() {
fs.createReadStream(tempFile, { start: '4', end: 6 });
}, "start as string didn't throw an error for createReadStream");
}, /^TypeError: start must be a Number$/,
"start as string didn't throw an error for createReadStream");

assert.throws(function() {
fs.createReadStream(tempFile, { start: 4, end: '6' });
}, "end as string didn't throw an error");
}, /^TypeError: end must be a Number$/,
"end as string didn't throw an error for createReadStream");

assert.throws(function() {
fs.createWriteStream(tempFile, { start: '4' });
}, "start as string didn't throw an error for createWriteStream");
}, /^TypeError: start must be a Number$/,
"start as string didn't throw an error for createWriteStream");

saneEmitter.on('data', function(data) {
saneEmitter.on('data', common.mustCall(function(data) {
assert.strictEqual(sanity, data.toString('utf8'), 'read ' +
data.toString('utf8') + ' instead of ' + sanity);
});
}));

0 comments on commit 11461ed

Please sign in to comment.