module: correct the order of the assertions

this puts the type-checking assertions in require
into proper order.

PR-URL: https://github.com/joyent/node/pull/8333
Reviewed-by: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
haoxin 2014-09-09 10:22:37 +08:00 committed by Chris Dickinson
parent 855b1c98ca
commit 00d7b13a18
2 changed files with 13 additions and 1 deletions

View File

@ -360,8 +360,8 @@ Module.prototype.load = function(filename) {
// Loads a module at the given file path. Returns that module's
// `exports` property.
Module.prototype.require = function(path) {
assert(util.isString(path), 'path must be a string');
assert(path, 'missing path');
assert(util.isString(path), 'path must be a string');
return Module._load(path, this);
};

View File

@ -42,3 +42,15 @@ try {
} catch (e) {
assert.notEqual(e.toString().indexOf(dlerror_msg), -1);
}
try {
require();
} catch (e) {
assert.notEqual(e.toString().indexOf('missing path'), -1);
}
try {
require({});
} catch (e) {
assert.notEqual(e.toString().indexOf('path must be a string'), -1);
}