Skip to content

Commit df835c4

Browse files
jasnellMylesBorins
authored andcommitted
test: add common.hasIntl
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>
1 parent ba2af51 commit df835c4

5 files changed

+11
-7
lines changed

test/common/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,12 @@ exports.expectWarning = function(name, expected) {
577577
}, expected.length));
578578
};
579579

580+
Object.defineProperty(exports, 'hasIntl', {
581+
get: function() {
582+
return process.binding('config').hasIntl;
583+
}
584+
});
585+
580586
// Crash the process on unhandled rejections.
581587
exports.crashOnUnhandledRejection = function() {
582588
process.on('unhandledRejection',

test/parallel/test-intl-v8BreakIterator.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
const common = require('../common');
33
const assert = require('assert');
44

5-
if (global.Intl === undefined || Intl.v8BreakIterator === undefined)
5+
if (!common.hasIntl || Intl.v8BreakIterator === undefined) {
66
common.skip('no Intl');
7+
}
78

89
try {
910
new Intl.v8BreakIterator();

test/parallel/test-intl.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ if (enablei18n === undefined) {
88
enablei18n = 0;
99
}
1010

11-
// is the Intl object present?
12-
const haveIntl = (global.Intl !== undefined);
13-
1411
// Returns true if no specific locale ids were configured (i.e. "all")
1512
// Else, returns true if loc is in the configured list
1613
// Else, returns false
@@ -19,7 +16,7 @@ function haveLocale(loc) {
1916
return locs.includes(loc);
2017
}
2118

22-
if (!haveIntl) {
19+
if (!common.hasIntl) {
2320
const erMsg =
2421
`"Intl" object is NOT present but v8_enable_i18n_support is ${enablei18n}`;
2522
assert.strictEqual(enablei18n, 0, erMsg);

test/parallel/test-process-versions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (common.hasCrypto) {
99
expected_keys.push('openssl');
1010
}
1111

12-
if (typeof Intl !== 'undefined') {
12+
if (common.hasIntl) {
1313
expected_keys.push('icu');
1414
}
1515

test/parallel/test-repl-tab-complete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ const testNonGlobal = repl.start({
344344
const builtins = [['Infinity', '', 'Int16Array', 'Int32Array',
345345
'Int8Array'], 'I'];
346346

347-
if (typeof Intl === 'object') {
347+
if (common.hasIntl) {
348348
builtins[0].push('Intl');
349349
}
350350
testNonGlobal.complete('I', common.mustCall((error, data) => {

0 commit comments

Comments
 (0)