Browse Source

core: throw TypeError if chdir() args are wrong

PR-URL: https://github.com/iojs/io.js/pull/274
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v1.8.0-commit
Caitlin Potter 10 years ago
committed by Ben Noordhuis
parent
commit
be2404e0d3
  1. 3
      src/node.cc
  2. 4
      test/sequential/test-chdir.js

3
src/node.cc

@ -1499,8 +1499,7 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if (args.Length() != 1 || !args[0]->IsString()) {
// FIXME(bnoordhuis) ThrowTypeError?
return env->ThrowError("Bad argument.");
return env->ThrowTypeError("Bad argument.");
}
node::Utf8Value path(args.GetIsolate(), args[0]);

4
test/sequential/test-chdir.js

@ -38,3 +38,7 @@ assert(process.cwd() == dir);
process.chdir('..');
assert(process.cwd() == path.resolve(common.fixturesDir));
fs.rmdirSync(dir);
assert.throws(function() { process.chdir({}); }, TypeError, 'Bad argument.');
assert.throws(function() { process.chdir(); }, TypeError, 'Bad argument.');
assert.throws(function() { process.chdir("x", "y"); }, TypeError, 'Bad argument.');

Loading…
Cancel
Save