getters-missing.js (2085B)
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 getters with missing tags. 8 info: | 9 get Intl.Locale.prototype.baseName 10 5. Return the substring of locale corresponding to the 11 language ["-" script] ["-" region] *("-" variant) 12 subsequence of the langtag grammar. 13 14 get Intl.Locale.prototype.language 15 4. Return the substring of locale corresponding to the language production. 16 17 get Intl.Locale.prototype.script 18 6. If locale does not contain the ["-" script] sequence, return undefined. 19 7. Return the substring of locale corresponding to the script production. 20 21 get Intl.Locale.prototype.region 22 6. If locale does not contain the ["-" region] sequence, return undefined. 23 7. Return the substring of locale corresponding to the region production. 24 features: [Intl.Locale] 25 ---*/ 26 27 // 'script' and 'region' subtags not present. 28 var loc = new Intl.Locale("sv"); 29 assert.sameValue(loc.baseName, "sv"); 30 assert.sameValue(loc.language, "sv"); 31 assert.sameValue(loc.script, undefined); 32 assert.sameValue(loc.region, undefined); 33 assert.sameValue(loc.variants, undefined); 34 35 // 'region' subtag not present. 36 var loc = new Intl.Locale("sv-Latn"); 37 assert.sameValue(loc.baseName, "sv-Latn"); 38 assert.sameValue(loc.language, "sv"); 39 assert.sameValue(loc.script, "Latn"); 40 assert.sameValue(loc.region, undefined); 41 assert.sameValue(loc.variants, undefined); 42 43 // 'script' subtag not present. 44 var loc = new Intl.Locale("sv-SE"); 45 assert.sameValue(loc.baseName, "sv-SE"); 46 assert.sameValue(loc.language, "sv"); 47 assert.sameValue(loc.script, undefined); 48 assert.sameValue(loc.region, "SE"); 49 assert.sameValue(loc.variants, undefined); 50 51 // 'variant' subtag present. 52 var loc = new Intl.Locale("de-1901"); 53 assert.sameValue(loc.baseName, "de-1901"); 54 assert.sameValue(loc.language, "de"); 55 assert.sameValue(loc.script, undefined); 56 assert.sameValue(loc.region, undefined); 57 assert.sameValue(loc.variants, '1901'); 58 59 reportCompare(0, 0);