From aa8771f84204b17adb843518a5814b1afdc6a0c6 Mon Sep 17 00:00:00 2001 From: Daijiro Wachi Date: Mon, 16 Jan 2017 22:34:04 +0100 Subject: [PATCH] test: use common.hasIntl in tests related to ICU We should use `common.hasIntl` in tests for test cases which are related to ICU. This way we can easily find the test cases that are Intl dependent. Plus, it will be able to make the tests a little faster if we check hasIntl first. Also, this tweaks the log messages to unify the message. Refs: https://github.com/nodejs/node/pull/10707 PR-URL: https://github.com/nodejs/node/pull/10841 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-icu-punycode.js | 12 ++++++------ test/parallel/test-icu-stringwidth.js | 10 +++++----- test/parallel/test-icu-transcode.js | 6 +++--- test/parallel/test-intl-v8BreakIterator.js | 4 ++-- test/parallel/test-whatwg-url-parsing.js | 2 +- test/parallel/test-whatwg-url-setters.js | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js index d9b36e7df78882..62508bc9f78f49 100644 --- a/test/parallel/test-icu-punycode.js +++ b/test/parallel/test-icu-punycode.js @@ -1,6 +1,11 @@ 'use strict'; - const common = require('../common'); + +if (!common.hasIntl) { + common.skip('missing Intl'); + return; +} + const icu = getPunycode(); const assert = require('assert'); @@ -12,11 +17,6 @@ function getPunycode() { } } -if (!icu) { - common.skip('icu punycode tests because ICU is not present.'); - return; -} - // Credit for list: http://www.i18nguy.com/markup/idna-examples.html const tests = [ 'افغانستا.icom.museum', diff --git a/test/parallel/test-icu-stringwidth.js b/test/parallel/test-icu-stringwidth.js index 5b66f00c32840c..80e798b13af154 100644 --- a/test/parallel/test-icu-stringwidth.js +++ b/test/parallel/test-icu-stringwidth.js @@ -1,15 +1,15 @@ // Flags: --expose_internals 'use strict'; - const common = require('../common'); -const assert = require('assert'); -const readline = require('internal/readline'); -if (!process.binding('config').hasIntl) { - common.skip('missing intl... skipping test'); +if (!common.hasIntl) { + common.skip('missing Intl'); return; } +const assert = require('assert'); +const readline = require('internal/readline'); + // Test column width assert.strictEqual(readline.getStringWidth('a'), 1); assert.strictEqual(readline.getStringWidth('丁'), 2); diff --git a/test/parallel/test-icu-transcode.js b/test/parallel/test-icu-transcode.js index 87f32a745a35cb..463b2fca9188ba 100644 --- a/test/parallel/test-icu-transcode.js +++ b/test/parallel/test-icu-transcode.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -const buffer = require('buffer'); -const assert = require('assert'); if (!common.hasIntl) { - common.skip('icu punycode tests because ICU is not present.'); + common.skip('missing Intl'); return; } +const buffer = require('buffer'); +const assert = require('assert'); const orig = Buffer.from('tést €', 'utf8'); // Test Transcoding diff --git a/test/parallel/test-intl-v8BreakIterator.js b/test/parallel/test-intl-v8BreakIterator.js index 4af3452b576f84..70f0f782bbc7e7 100644 --- a/test/parallel/test-intl-v8BreakIterator.js +++ b/test/parallel/test-intl-v8BreakIterator.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); if (!common.hasIntl || Intl.v8BreakIterator === undefined) { - return common.skip('no Intl'); + return common.skip('missing Intl'); } +const assert = require('assert'); const warning = 'Intl.v8BreakIterator is deprecated and will be removed soon.'; common.expectWarning('DeprecationWarning', warning); diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index c83d30da414571..9ea6cc74bff5e6 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -4,7 +4,7 @@ const common = require('../common'); if (!common.hasIntl) { // A handful of the tests fail when ICU is not included. - common.skip('missing Intl... skipping test'); + common.skip('missing Intl'); return; } diff --git a/test/parallel/test-whatwg-url-setters.js b/test/parallel/test-whatwg-url-setters.js index 3b2aca2afd89d7..236737e18177fe 100644 --- a/test/parallel/test-whatwg-url-setters.js +++ b/test/parallel/test-whatwg-url-setters.js @@ -4,7 +4,7 @@ const common = require('../common'); if (!common.hasIntl) { // A handful of the tests fail when ICU is not included. - common.skip('missing Intl... skipping test'); + common.skip('missing Intl'); return; }