From f4ce7c1ee72d898a855a21a4f9ef1e726ae772d3 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 23 Oct 2016 10:00:41 -0700 Subject: [PATCH 1/2] test: add common.hasIntl --- test/common.js | 6 ++++++ test/parallel/test-intl-v8BreakIterator.js | 2 +- test/parallel/test-intl.js | 5 +---- test/parallel/test-process-versions.js | 2 +- test/parallel/test-repl-tab-complete.js | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/test/common.js b/test/common.js index 7299ece32f9cef..e0ce68c835b483 100644 --- a/test/common.js +++ b/test/common.js @@ -525,3 +525,9 @@ exports.expectWarning = function(name, expected) { expected.splice(expected.indexOf(warning.message), 1); }, expected.length)); }; + +Object.defineProperty(exports, 'hasIntl', { + get: function() { + return process.binding('config').hasIntl; + } +}); diff --git a/test/parallel/test-intl-v8BreakIterator.js b/test/parallel/test-intl-v8BreakIterator.js index f6922bcd9b7314..4af3452b576f84 100644 --- a/test/parallel/test-intl-v8BreakIterator.js +++ b/test/parallel/test-intl-v8BreakIterator.js @@ -2,7 +2,7 @@ const common = require('../common'); const assert = require('assert'); -if (global.Intl === undefined || Intl.v8BreakIterator === undefined) { +if (!common.hasIntl || Intl.v8BreakIterator === undefined) { return common.skip('no Intl'); } diff --git a/test/parallel/test-intl.js b/test/parallel/test-intl.js index 3b56defe471af0..938099f2e3c6b9 100644 --- a/test/parallel/test-intl.js +++ b/test/parallel/test-intl.js @@ -8,9 +8,6 @@ if (enablei18n === undefined) { enablei18n = 0; } -// is the Intl object present? -const haveIntl = (global.Intl !== undefined); - // Returns true if no specific locale ids were configured (i.e. "all") // Else, returns true if loc is in the configured list // Else, returns false @@ -19,7 +16,7 @@ function haveLocale(loc) { return locs.indexOf(loc) !== -1; } -if (!haveIntl) { +if (!common.hasIntl) { const erMsg = '"Intl" object is NOT present but v8_enable_i18n_support is ' + enablei18n; diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 12136958fc8c37..0b86cfd7343df1 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -9,7 +9,7 @@ if (common.hasCrypto) { expected_keys.push('openssl'); } -if (typeof Intl !== 'undefined') { +if (common.hasIntl) { expected_keys.push('icu'); } diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js index e8fc5b1863caa3..77c14deaf3b023 100644 --- a/test/parallel/test-repl-tab-complete.js +++ b/test/parallel/test-repl-tab-complete.js @@ -277,7 +277,7 @@ const testNonGlobal = repl.start({ const builtins = [['Infinity', '', 'Int16Array', 'Int32Array', 'Int8Array'], 'I']; -if (typeof Intl === 'object') { +if (common.hasIntl) { builtins[0].push('Intl'); } testNonGlobal.complete('I', common.mustCall((error, data) => { From 99cd46d49186949e307b268a9de4553264eed946 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 23 Oct 2016 08:08:39 -0700 Subject: [PATCH 2/2] test: skip whatwg url parse and setter tests when icu is missing the WHATWG url parser relies on ICU's punycode implementation. A handful of the standard tests fail when ICU is not present because of the additional checks that are not implemented. For now, skip the parse and setter tests if ICU is not present. --- test/parallel/test-whatwg-url-parsing.js | 7 +++++++ test/parallel/test-whatwg-url-setters.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 568bc821758dd5..40ada010c1dd36 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -1,6 +1,13 @@ 'use strict'; const common = require('../common'); + +if (!common.hasIntl) { + // A handful of the tests fail when ICU is not included. + common.skip('missing Intl... skipping test'); + return; +} + const URL = require('url').URL; const path = require('path'); const assert = require('assert'); diff --git a/test/parallel/test-whatwg-url-setters.js b/test/parallel/test-whatwg-url-setters.js index 4c29ef098cc463..3b2aca2afd89d7 100644 --- a/test/parallel/test-whatwg-url-setters.js +++ b/test/parallel/test-whatwg-url-setters.js @@ -1,6 +1,13 @@ 'use strict'; const common = require('../common'); + +if (!common.hasIntl) { + // A handful of the tests fail when ICU is not included. + common.skip('missing Intl... skipping test'); + return; +} + const path = require('path'); const URL = require('url').URL; const assert = require('assert');