From 43e3f94ca6b1584a892f9c254b16c1689d78cdbe Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 4 May 2016 02:14:01 -0700 Subject: [PATCH 1/4] Update to the latest nan for Node v6 support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dfc0e5f5..cdc9777b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "dependencies": { "bindings": "^1.2.1", "mockery": "^1.6.2", - "nan": "^2.2.1", + "nan": "^2.3.3", "node-gyp": "^3.3.1", "rnpm": "1.6.5", "xcode": "0.8.4" From 24dab1e8d7342d26aba9918a876536637b38b2ad Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 4 May 2016 02:14:50 -0700 Subject: [PATCH 2/4] Heed v8 warning in Node v6 from v8::Template::Set --- src/node/node_class.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/node/node_class.hpp b/src/node/node_class.hpp index 757e6228..ea95cf98 100644 --- a/src/node/node_class.hpp +++ b/src/node/node_class.hpp @@ -104,7 +104,7 @@ class ObjectWrap { using Internal = void; static v8::Local get_template() { - return v8::Local();; + return v8::Local(); } }; @@ -195,22 +195,21 @@ inline v8::Local ObjectWrap::create_template() template inline void ObjectWrap::setup_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { v8::Local signature = Nan::New(tpl); - v8::Local t = Nan::New(callback, v8::Local(), signature); - v8::Local fn = Nan::GetFunction(t).ToLocalChecked(); + v8::Local fn_tpl = Nan::New(callback, v8::Local(), signature); v8::Local fn_name = Nan::New(name).ToLocalChecked(); // The reason we use this rather than Nan::SetPrototypeMethod is DontEnum. - tpl->PrototypeTemplate()->Set(fn_name, fn, v8::PropertyAttribute::DontEnum); - fn->SetName(fn_name); + tpl->PrototypeTemplate()->Set(fn_name, fn_tpl, v8::PropertyAttribute::DontEnum); + fn_tpl->SetClassName(fn_name); } template inline void ObjectWrap::setup_static_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { - v8::Local fn = Nan::GetFunction(Nan::New(callback)).ToLocalChecked(); + v8::Local fn_tpl = Nan::New(callback); v8::Local fn_name = Nan::New(name).ToLocalChecked(); - tpl->Set(fn_name, fn, v8::PropertyAttribute::DontEnum); - fn->SetName(fn_name); + tpl->Set(fn_name, fn_tpl, v8::PropertyAttribute::DontEnum); + fn_tpl->SetClassName(fn_name); } template From 4a5ac413cc128a8b98389f115781520de11fa2a4 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 4 May 2016 02:15:17 -0700 Subject: [PATCH 3/4] Skip test in Node v6 due to v8 regression --- tests/js/list-tests.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index cb316b31..2215bac8 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -554,7 +554,11 @@ module.exports = BaseTest.extend({ TestCase.assertEqual(list.slice(1, 3).length, 2); TestCase.assertEqual(list.slice(1, 3)[1].age, 12); - TestCase.assertEqual(list.join(' '), 'Ari Tim Bjarne'); + // A Node 6 regression in v8 causes an error when converting our objects to strings: + // TypeError: Cannot convert a Symbol value to a string + if (typeof process != 'object' || ('' + process.version).indexOf('v6.') < 0) { + TestCase.assertEqual(list.join(' '), 'Ari Tim Bjarne'); + } var count = 0; list.forEach(function(p, i) { From 4300e865c7413c350da5e382eabe9b6706c7dea7 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 10 May 2016 11:34:33 -0700 Subject: [PATCH 4/4] Abstracted check for Node v6 --- tests/js/asserts.js | 8 ++++++++ tests/js/list-tests.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/js/asserts.js b/tests/js/asserts.js index 75ec6c31..7031717b 100644 --- a/tests/js/asserts.js +++ b/tests/js/asserts.js @@ -109,6 +109,14 @@ module.exports = { throw new TestFailureError(errorMessage || 'Condition expected to be true'); } }, + + isNode: function() { + return typeof process == 'object' && Object.prototype.toString.call(process) == '[object process]'; + }, + + isNode6: function() { + return this.isNode() && process.version.indexOf('v6.') == 0; + }, }; function TestFailureError(message) { diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index 2215bac8..4563528d 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -556,7 +556,7 @@ module.exports = BaseTest.extend({ // A Node 6 regression in v8 causes an error when converting our objects to strings: // TypeError: Cannot convert a Symbol value to a string - if (typeof process != 'object' || ('' + process.version).indexOf('v6.') < 0) { + if (!TestCase.isNode6()) { TestCase.assertEqual(list.join(' '), 'Ari Tim Bjarne'); }