From 4300e865c7413c350da5e382eabe9b6706c7dea7 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 10 May 2016 11:34:33 -0700 Subject: [PATCH] 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'); }