Skip to content

Commit

Permalink
test: add common.hasIntl
Browse files Browse the repository at this point in the history
Backport-PR-URL: #17365
PR-URL: #9246
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
jasnell authored and MylesBorins committed Feb 13, 2018
1 parent a6d2384 commit 699c663
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-intl-v8BreakIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (common.hasCrypto) {
expected_keys.push('openssl');
}

if (typeof Intl !== 'undefined') {
if (common.hasIntl) {
expected_keys.push('icu');
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 699c663

Please sign in to comment.