Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixed segfault and also works in node 0.5.5 #12

Merged
merged 4 commits into from

3 participants

Vadim Graboys James Halliday Roman Shtylman
Vadim Graboys

bigint segfaulted when passed a null or undefined. This fixes that by throwing an exception instead. Also, fixed some tests and made it work in node 0.5.5.

A question about test/seed.js: why does it spawn 2 processes? Why does it assert that n1 != n2? This test will fail .1% of the time.

James Halliday
Owner

I wrote test/seed.js because there was a bug where the seed wasn't getting initialized randomly on start up so the random values would be the same every time a program ran. The test spawns two processes to make sure that the values are actually different.

James Halliday substack merged commit f752515 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 1, 2011
  1. Vadim Graboys
  2. Roman Shtylman

    fix package.json file "scripts" section

    defunctzombie authored
    Cannot have two scripts sections, the second overrides the first
  3. Roman Shtylman
  4. Vadim Graboys

    also works in node < 0.5.5

    vadimg authored
This page is out of date. Refresh to see the latest.
4 bigint.cc
View
@@ -231,6 +231,10 @@ BigInt::New(const Arguments& args)
}
Local<Value> obj = js_conditioner->Call(ctx, args.Length(), newArgs);
+ if(!*obj) {
+ return ThrowException(Exception::Error(String::New("Invalid type passed to bigint constructor")));
+ }
+
String::Utf8Value str(obj->ToObject()->Get(String::NewSymbol("num"))->ToString());
base = obj->ToObject()->Get(String::NewSymbol("base"))->ToNumber()->Value();
8 index.js
View
@@ -1,4 +1,10 @@
-var cc = new require('./build/default/bigint');
+try {
+ // node.js versions < 0.5.5
+ var cc = new require('./build/default/bigint');
+} catch(e) {
+ // node.js versions >= 0.5.5
+ var cc = new require('./build/Release/bigint');
+}
var BigInt = cc.BigInt;
module.exports = BigInt;
9 package.json
View
@@ -24,16 +24,15 @@
},
"devDependencies" : {
"expresso" : ">=0.6.0",
- "binary" : ">=0.1.7"
- },
- "scripts" : {
- "test" : "expresso"
+ "binary" : ">=0.1.7",
+ "put" : ">=0.0.5"
},
"license" : "MIT/X11",
"engine" : {
"node" : ">=0.2.0"
},
"scripts" : {
- "install" : "node-waf configure build"
+ "install" : "node-waf configure build",
+ "test" : "expresso"
}
}
3  test/big.js
View
@@ -20,6 +20,9 @@ exports.create = function () {
}
assert.eql(bigint('1.23e-45').toString(), '0');
+
+ assert.throws(function() { bigint(undefined); });
+ assert.throws(function() { bigint(null); });
};
exports.add = function () {
4 test/seed.js
View
@@ -6,9 +6,9 @@ exports.rand = function () {
assert.fail('never executed');
}, 5000);
- var cmd = 'node -e \'require('
+ var cmd = 'node -e \'console.log(require('
+ JSON.stringify(__dirname + '/../')
- + ').rand(1000).toString()\''
+ + ').rand(1000).toString())\''
;
exec(cmd, function (err1, r1) {
exec(cmd, function (err2, r2) {
Something went wrong with that request. Please try again.