Browse Source

process: improve process binding

Reviewed-By: Fedor Indutny <fedor@indutny.com>
archived-io.js-v0.10
Jackson Tian 10 years ago
committed by Fedor Indutny
parent
commit
962e651476
  1. 7
      src/node.cc
  2. 16
      test/simple/test-process-binding.js

7
src/node.cc

@ -2240,7 +2240,12 @@ static void Binding(const FunctionCallbackInfo<Value>& args) {
DefineJavaScript(env, exports);
cache->Set(module, exports);
} else {
return env->ThrowError("No such module");
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"No such module: %s",
*module_v);
return env->ThrowError(errmsg);
}
args.GetReturnValue().Set(exports);

16
test/simple/test-process-binding.js

@ -0,0 +1,16 @@
var assert = require('assert');
assert.throws(
function() {
process.binding('test');
},
/No such module: test/
);
assert.doesNotThrow(function () {
process.binding('buffer');
}, function(err) {
if ( (err instanceof Error) ) {
return true;
}
}, "unexpected error");
Loading…
Cancel
Save