mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c4b8b201a
Refs: https://github.com/nodejs/node/pull/41660 PR-URL: https://github.com/nodejs/node/pull/41678 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
27 lines
693 B
JavaScript
27 lines
693 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}];
|
|
|
|
function testMakeStatsCallback(cb) {
|
|
return function() {
|
|
// fs.stat() calls makeStatsCallback() on its second argument
|
|
fs.stat(__filename, cb);
|
|
};
|
|
}
|
|
|
|
// Verify the case where a callback function is provided
|
|
testMakeStatsCallback(common.mustCall())();
|
|
|
|
function invalidCallbackThrowsTests() {
|
|
callbackThrowValues.forEach((value) => {
|
|
assert.throws(testMakeStatsCallback(value), {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
name: 'TypeError'
|
|
});
|
|
});
|
|
}
|
|
|
|
invalidCallbackThrowsTests();
|