Fix timeouts with floating point numbers bug
authorRyan Dahl <ry@tinyclouds.org>
Fri, 22 Apr 2011 23:38:27 +0000 (16:38 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 22 Apr 2011 23:38:29 +0000 (16:38 -0700)
fixes #897.

src/node.h
test/simple/test-regress-GH-897.js [new file with mode: 0644]

index 06135d6..14d726d 100644 (file)
@@ -43,7 +43,7 @@ int Start (int argc, char *argv[]);
 
 /* Converts a unixtime to V8 Date */
 #define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
-#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->IntegerValue())/1000.0);
+#define NODE_V8_UNIXTIME(v) (static_cast<double>((v)->NumberValue())/1000.0);
 
 #define NODE_DEFINE_CONSTANT(target, constant)                            \
   (target)->Set(v8::String::NewSymbol(#constant),                         \
diff --git a/test/simple/test-regress-GH-897.js b/test/simple/test-regress-GH-897.js
new file mode 100644 (file)
index 0000000..7103a72
--- /dev/null
@@ -0,0 +1,14 @@
+var common = require('../common');
+var assert = require('assert');
+
+var t = Date.now();
+var diff;
+setTimeout(function () {
+  diff = Date.now() - t;
+  console.error(diff);
+}, 0.1);
+
+
+process.on('exit', function() {
+  assert.ok(diff < 10);
+});