THRIFT-2443: node fails cross lang tests
Client: node
Patch: Randy Abernethy

adds support for recursive tests of i64 types and fixes cross
lang test failure with C++.
diff --git a/lib/nodejs/test/thrift_test_driver.js b/lib/nodejs/test/thrift_test_driver.js
index c61e99d..ccc105b 100644
--- a/lib/nodejs/test/thrift_test_driver.js
+++ b/lib/nodejs/test/thrift_test_driver.js
@@ -17,7 +17,7 @@
  * under the License.

  */

 

- // This is the Node test driver for the standard Apache Thrift 

+ // This is the Node.js test driver for the standard Apache Thrift 

  // test service. The driver invokes every function defined in the 

  // Thrift Test service with a representative range of parameters.

  //

@@ -28,14 +28,21 @@
 

 var assert = require('assert');

 var ttypes = require('./gen-nodejs/ThriftTest_types');

+var Int64 = require('node-int64');

 

 var ThriftTestDriver = exports.ThriftTestDriver = function(client, callback) {

 	

-// deepEqual doesn't work with fields using node-int64

 function checkRecursively(map1, map2) {

   if (typeof map1 !== 'function' && typeof map2 !== 'function') {

     if (!map1 || typeof map1 !== 'object') {

+      //Handle int64 types (which use node-int64 in Node.js JavaScript)

+      if ((typeof map1 === "number") && (typeof map2 === "object") && 

+          (map2.buffer) && (map2.buffer instanceof Buffer) && (map2.buffer.length === 8)) {

+        var n = new Int64(map2.buffer);

+        assert.equal(map1, n.toNumber());          

+      } else {

         assert.equal(map1, map2);

+      }

     } else {

       for (var key in map1) {

         checkRecursively(map1[key], map2[key]);

@@ -235,7 +242,7 @@
 });

 var insanity = {

   "1":{ "2": crazy, "3": crazy },

-  "2":{ "6":{ "userMap":null, "xtructs":null } }

+  "2":{ "6":{ "userMap":{}, "xtructs":[] } }

 };

 client.testInsanity(crazy, function(err, response) {

   assert( ! err);