casing-numbering-system-calendar-options.js (1783B)
1 // Copyright 2020 Google Inc, Igalia S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-createdatetimeformat 6 description: > 7 Tests that the options numberingSystem and calendar are mapped 8 to lower case properly. 9 author: Caio Lima 10 features: [Array.prototype.includes] 11 ---*/ 12 13 let defaultLocale = new Intl.DateTimeFormat().resolvedOptions().locale; 14 15 let supportedNumberingSystems = ["latn", "arab"].filter(nu => 16 new Intl.DateTimeFormat(defaultLocale + "-u-nu-" + nu) 17 .resolvedOptions().numberingSystem === nu 18 ); 19 20 if (supportedNumberingSystems.includes("latn")) { 21 let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-nu-lATn"); 22 assert.sameValue(dateTimeFormat.resolvedOptions().numberingSystem, "latn", "Numbering system option should be in lower case"); 23 } 24 25 if (supportedNumberingSystems.includes("arab")) { 26 let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-nu-Arab"); 27 assert.sameValue(dateTimeFormat.resolvedOptions().numberingSystem, "arab", "Numbering system option should be in lower case"); 28 } 29 30 let supportedCalendars = ["gregory", "chinese"].filter(ca => 31 new Intl.DateTimeFormat(defaultLocale + "-u-ca-" + ca) 32 .resolvedOptions().calendar === ca 33 ); 34 35 if (supportedCalendars.includes("gregory")) { 36 let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-ca-Gregory"); 37 assert.sameValue(dateTimeFormat.resolvedOptions().calendar, "gregory", "Calendar option should be in lower case"); 38 } 39 40 if (supportedCalendars.includes("chinese")) { 41 let dateTimeFormat = new Intl.DateTimeFormat(defaultLocale + "-u-ca-CHINESE"); 42 assert.sameValue(dateTimeFormat.resolvedOptions().calendar, "chinese", "Calendar option should be in lower case"); 43 } 44 45 46 reportCompare(0, 0);