extensions-grandfathered.js (1919B)
1 // Copyright 2018 André Bargull; 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-intl.locale 6 description: > 7 Verifies handling of options with grandfathered tags. 8 info: | 9 ApplyOptionsToTag( tag, options ) 10 ... 11 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. 12 13 IsStructurallyValidLanguageTag ( locale ) 14 15 The IsStructurallyValidLanguageTag abstract operation verifies that the 16 locale argument (which must be a String value) 17 18 represents a well-formed Unicode BCP 47 Locale Identifier" as specified in 19 Unicode Technical Standard 35 section 3.2, or successor, 20 21 features: [Intl.Locale] 22 ---*/ 23 24 const testData = [ 25 // Regular grandfathered without modern replacement. 26 { 27 tag: "cel-gaulish", 28 options: { 29 language: "fr", 30 script: "Cyrl", 31 region: "FR", 32 numberingSystem: "latn", 33 }, 34 canonical: "fr-Cyrl-FR-u-nu-latn", 35 }, 36 37 // Regular grandfathered with modern replacement. 38 { 39 tag: "art-lojban", 40 options: { 41 language: "fr", 42 script: "Cyrl", 43 region: "ZZ", 44 numberingSystem: "latn", 45 }, 46 canonical: "fr-Cyrl-ZZ-u-nu-latn", 47 }, 48 ]; 49 50 for (const {tag, options, canonical} of testData) { 51 const loc = new Intl.Locale(tag, options); 52 assert.sameValue(loc.toString(), canonical); 53 54 for (const [name, value] of Object.entries(options)) { 55 assert.sameValue(loc[name], value); 56 } 57 } 58 59 assert.throws(RangeError, () => 60 new Intl.Locale("i-default", 61 {language: "fr", script: "Cyrl", region: "DE", numberingSystem: "latn"} 62 )); 63 64 assert.throws(RangeError, () => 65 new Intl.Locale("en-gb-oed", 66 {language: "fr", script: "Cyrl", region: "US", numberingSystem: "latn"} 67 )); 68 69 reportCompare(0, 0);