diff --git a/test/common/index.js b/test/common/index.js index 6ea3d89f0b9a37..7747cb57cf3ae7 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -577,6 +577,12 @@ exports.expectWarning = function(name, expected) { }, expected.length)); }; +Object.defineProperty(exports, 'hasIntl', { + get: function() { + return process.binding('config').hasIntl; + } +}); + // Crash the process on unhandled rejections. exports.crashOnUnhandledRejection = function() { process.on('unhandledRejection', diff --git a/test/parallel/test-intl-v8BreakIterator.js b/test/parallel/test-intl-v8BreakIterator.js index 03e0712ba3ece2..7ccdb70f141a8b 100644 --- a/test/parallel/test-intl-v8BreakIterator.js +++ b/test/parallel/test-intl-v8BreakIterator.js @@ -2,8 +2,9 @@ const common = require('../common'); const assert = require('assert'); -if (global.Intl === undefined || Intl.v8BreakIterator === undefined) +if (!common.hasIntl || Intl.v8BreakIterator === undefined) { common.skip('no Intl'); +} try { new Intl.v8BreakIterator(); diff --git a/test/parallel/test-intl.js b/test/parallel/test-intl.js index a5b76538a2e722..907f56f03ac83f 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.includes(loc); } -if (!haveIntl) { +if (!common.hasIntl) { const erMsg = `"Intl" object is NOT present but v8_enable_i18n_support is ${enablei18n}`; assert.strictEqual(enablei18n, 0, erMsg); diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 27311f7eda84e3..b0377afd4a1899 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 0d05196869cda9..d29d816a425976 100644 --- a/test/parallel/test-repl-tab-complete.js +++ b/test/parallel/test-repl-tab-complete.js @@ -344,7 +344,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) => {