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) => {