From 50de5f98abe166448da1be1dca0b3dd049dce883 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Thu, 17 May 2018 17:30:48 -0400 Subject: [PATCH] Intl.Locale: ensure that the expect value is correctly printed in the assertion message --- .../constructor-options-hourcycle-valid.js | 22 +++++++----- .../constructor-options-language-valid.js | 34 ++++++++++-------- .../constructor-options-region-valid.js | 27 ++++++++------ .../constructor-options-script-valid.js | 36 ++++++++++--------- 4 files changed, 69 insertions(+), 50 deletions(-) diff --git a/test/intl402/Locale/constructor-options-hourcycle-valid.js b/test/intl402/Locale/constructor-options-hourcycle-valid.js index 7015b5338d..dc371a92cb 100644 --- a/test/intl402/Locale/constructor-options-hourcycle-valid.js +++ b/test/intl402/Locale/constructor-options-hourcycle-valid.js @@ -36,32 +36,38 @@ features: [Intl.Locale] ---*/ const validHourCycleOptions = [ - "h11", - "h12", - "h23", - "h24", - { toString() { return "h24"; } }, + 'h11', + 'h12', + 'h23', + 'h24', + { toString() { return 'h24'; } }, ]; for (const hourCycle of validHourCycleOptions) { const options = { hourCycle }; const expected = String(hourCycle); + let expect = 'en-u-hc-' + expected; + assert.sameValue( new Intl.Locale('en', options).toString(), - "en-u-hc-" + expected, + expect, + `new Intl.Locale('en', options).toString() equals the value of ${expect}` ); assert.sameValue( new Intl.Locale('en-u-hc-h00', options).toString(), - "en-u-hc-" + expected, + expect, + `new Intl.Locale('en-u-hc-h00', options).toString() equals the value of ${expect}` ); assert.sameValue( new Intl.Locale('en-u-hc-h12', options).toString(), - "en-u-hc-" + expected, + expect, + `new Intl.Locale('en-u-hc-h12', options).toString() equals the value of ${expect}` ); assert.sameValue( new Intl.Locale('en-u-hc-h00', options).hourCycle, expected, + `new Intl.Locale('en-u-hc-h00', options).hourCycle equals the value of ${expect}` ); } diff --git a/test/intl402/Locale/constructor-options-language-valid.js b/test/intl402/Locale/constructor-options-language-valid.js index 4a2be5aa17..57c4fb9bf1 100644 --- a/test/intl402/Locale/constructor-options-language-valid.js +++ b/test/intl402/Locale/constructor-options-language-valid.js @@ -24,33 +24,37 @@ features: [Intl.Locale] const validLanguageOptions = [ [undefined, undefined], - [null, "null"], - ["zh-cmn", "cmn"], - ["ZH-CMN", "cmn"], - ["abcd", "abcd"], - ["abcde", "abcde"], - ["abcdef", "abcdef"], - ["abcdefg", "abcdefg"], - ["abcdefgh", "abcdefgh"], - [{ toString() { return "de" } }, "de"], + [null, 'null'], + ['zh-cmn', 'cmn'], + ['ZH-CMN', 'cmn'], + ['abcd', 'abcd'], + ['abcde', 'abcde'], + ['abcdef', 'abcdef'], + ['abcdefg', 'abcdefg'], + ['abcdefgh', 'abcdefgh'], + [{ toString() { return 'de' } }, 'de'], ]; for (const [language, expected] of validLanguageOptions) { let options = { language }; + let expect = expected || 'en'; + assert.sameValue( new Intl.Locale('en', options).toString(), - expected || 'en', - `new Intl.Locale('en', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en', options).toString() equals the value of ${expect}` ); + expect = (expected || 'en') + '-US'; assert.sameValue( new Intl.Locale('en-US', options).toString(), - (expected || "en") + "-US", - `new Intl.Locale('en-US', options).toString() equals the value of ${expected}-US` + expected, + `new Intl.Locale('en-US', options).toString() equals the value of ${expect}` ); + expect = expected || 'en-els'; assert.sameValue( new Intl.Locale('en-els', options).toString(), - expected || "en-els", - `new Intl.Locale('en-els', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en-els', options).toString() equals the value of ${expect}` ); } diff --git a/test/intl402/Locale/constructor-options-region-valid.js b/test/intl402/Locale/constructor-options-region-valid.js index 17d0d0b76f..f9cb7eaddf 100644 --- a/test/intl402/Locale/constructor-options-region-valid.js +++ b/test/intl402/Locale/constructor-options-region-valid.js @@ -30,33 +30,38 @@ features: [Intl.Locale] const validRegionOptions = [ [undefined, undefined], - ["FR", "en-FR"], - ["554", "en-554"], - [554, "en-554"], + ['FR', 'en-FR'], + ['554', 'en-554'], + [554, 'en-554'], ]; for (const [region, expected] of validRegionOptions) { let options = { region }; + let expect = expected || 'en'; + assert.sameValue( new Intl.Locale('en', options).toString(), - expected || "en", - `new Intl.Locale('en', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en', options).toString() equals the value of ${expect}` ); + expect = expected || 'en-US'; assert.sameValue( new Intl.Locale('en-US', options).toString(), - expected || "en-US", - `new Intl.Locale('en-US', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en-US', options).toString() equals the value of ${expect}` ); + expect = (expected || 'en') + '-u-ca-gregory'; assert.sameValue( new Intl.Locale('en-u-ca-gregory', options).toString(), - (expected || "en") + "-u-ca-gregory", - `new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en-u-ca-gregory', options).toString() equals the value of ${expect}` ); + expect = (expected || 'en-US') + '-u-ca-gregory'; assert.sameValue( new Intl.Locale('en-US-u-ca-gregory', options).toString(), - (expected || "en-US") + "-u-ca-gregory", - `new Intl.Locale('en-US-u-ca-gregory', options).toString() equals the value of ${expected}` + expect, + `new Intl.Locale('en-US-u-ca-gregory', options).toString() equals the value of ${expect}` ); } diff --git a/test/intl402/Locale/constructor-options-script-valid.js b/test/intl402/Locale/constructor-options-script-valid.js index 53564ff7da..8104cb97cc 100644 --- a/test/intl402/Locale/constructor-options-script-valid.js +++ b/test/intl402/Locale/constructor-options-script-valid.js @@ -31,29 +31,33 @@ features: [Intl.Locale] const validScriptOptions = [ [undefined, undefined], - [null, "Null"], - ["bali", "Bali"], - ["Bali", "Bali"], - ["bALI", "BALI"], // TODO REVIEW: is this the correct case regularization? - [{ toString() { return "Brai" } }, "Brai"], + [null, 'Null'], + ['bali', 'Bali'], + ['Bali', 'Bali'], + ['bALI', 'BALI'], // TODO REVIEW: is this the correct case regularization? + [{ toString() { return 'Brai' } }, 'Brai'], ]; for (const [script, expected] of validScriptOptions) { let options = { script }; - assert.sameValue( - new Intl.Locale("en", options).toString(), - expected ? ("en-" + expected) : "en", - `new Intl.Locale("en", options).toString() equals the value of ${expected}` - ); + let expect = expected ? 'en-' + expected : 'en'; assert.sameValue( - new Intl.Locale("en-DK", options).toString(), - (expected ? ("en-" + expected) : "en") + "-DK", - `new Intl.Locale("en", options).toString() equals the value of ${expected}` + new Intl.Locale('en', options).toString(), + expect, + `new Intl.Locale('en', options).toString() equals the value of ${expect}` ); + expect = (expected ? ('en-' + expected) : 'en') + '-DK'; assert.sameValue( - new Intl.Locale("en-Cyrl", options).toString(), - expected ? ("en-" + expected) : "en-Cyrl", - `new Intl.Locale("en-Cyrl", options).toString() equals the value of ${expected}` + new Intl.Locale('en-DK', options).toString(), + expect, + `new Intl.Locale('en', options).toString() equals the value of ${expect}` + ); + + expect = expected ? ('en-' + expected) : 'en-Cyrl'; + assert.sameValue( + new Intl.Locale('en-Cyrl', options).toString(), + expect, + `new Intl.Locale('en-Cyrl', options).toString() equals the value of ${expect}` ); }