From 5d5904d69a67adad5aa25336c39798c47097984e Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Mon, 10 Feb 2020 17:28:20 -0300 Subject: [PATCH] Adding test cases to verify that 'numberingSystem' and 'calendar' options are being mapped to lower case --- ...asing-numbering-system-calendar-options.js | 43 +++++++++++++++++++ .../casing-numbering-system-options.js | 26 +++++++++++ 2 files changed, 69 insertions(+) create mode 100644 test/intl402/DateTimeFormat/casing-numbering-system-calendar-options.js create mode 100644 test/intl402/NumberFormat/casing-numbering-system-options.js diff --git a/test/intl402/DateTimeFormat/casing-numbering-system-calendar-options.js b/test/intl402/DateTimeFormat/casing-numbering-system-calendar-options.js new file mode 100644 index 0000000000..0753f79e0f --- /dev/null +++ b/test/intl402/DateTimeFormat/casing-numbering-system-calendar-options.js @@ -0,0 +1,43 @@ +// Copyright 2020 Google Inc, Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: > + Tests that the options numberingSystem and calendar are mapped + to lower case properly. +author: Caio Lima +---*/ + +let defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; + +let supportedNumberingSystems = ["latn", "arab"].filter(nu => + new Intl.DateTimeFormat(defaultLocale + "-u-nu-" + nu) + .resolvedOptions().numberingSystem === nu +); + +if (supportedNumberingSystems.includes("latn")) { + let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-nu-lATn"); + assert.sameValue(dateTimeFormat.resolvedOptions().numberingSystem, "latn", "Numbering system option should be in lower case"); +} + +if (supportedNumberingSystems.includes("arab")) { + let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-nu-Arab"); + assert.sameValue(dateTimeFormat.resolvedOptions().numberingSystem, "arab", "Numbering system option should be in lower case"); +} + +let supportedCalendars = ["gregory", "chinese"].filter(ca => + new Intl.DateTimeFormat(defaultLocale + "-u-ca-" + ca) + .resolvedOptions().calendar === ca +); + +if (supportedCalendars.includes("gregory")) { + let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-ca-Gregory"); + assert.sameValue(dateTimeFormat.resolvedOptions().calendar, "gregory", "Calendar option should be in lower case"); +} + +if (supportedCalendars.includes("chinese")) { + let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-ca-CHINESE"); + assert.sameValue(dateTimeFormat.resolvedOptions().calendar, "chinese", "Calendar option should be in lower case"); +} + diff --git a/test/intl402/NumberFormat/casing-numbering-system-options.js b/test/intl402/NumberFormat/casing-numbering-system-options.js new file mode 100644 index 0000000000..8e927a9c3a --- /dev/null +++ b/test/intl402/NumberFormat/casing-numbering-system-options.js @@ -0,0 +1,26 @@ +// Copyright 2020 Google Inc, Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializenumberformat +description: > + Tests that the options numberingSystem are mapped to lower case. +author: Caio Lima +---*/ + +let defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; + +let supportedNumberingSystems = ["latn", "arab"].filter(nu => + new Intl.NumberFormat(defaultLocale + "-u-nu-" + nu) + .resolvedOptions().numberingSystem === nu +); + +if (supportedNumberingSystems.includes("latn")) { + let numberFormat = new Intl.NumberFormat(defaultLocale + "-u-nu-lATn"); + assert.sameValue(numberFormat.resolvedOptions().numberingSystem, "latn", "Numbering system option should be in lower case"); +} + +if (supportedNumberingSystems.includes("arab")) { + let numberFormat = new Intl.NumberFormat(defaultLocale + "-u-nu-Arab"); + assert.sameValue(numberFormat.resolvedOptions().numberingSystem, "arab", "Numbering system option should be in lower case"); +}