constructor-locale-object.js (1276B)
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 canonicalization of specific tags. 8 info: | 9 ApplyOptionsToTag( tag, options ) 10 10. Return CanonicalizeLanguageTag(tag). 11 features: [Intl.Locale] 12 ---*/ 13 14 // Pass Intl.Locale object and replace subtag. 15 const enUS = new Intl.Locale("en-US"); 16 const enGB = new Intl.Locale(enUS, {region: "GB"}); 17 18 assert.sameValue(enUS.toString(), "en-US", 'enUS.toString() returns "en-US"'); 19 assert.sameValue(enGB.toString(), "en-GB", 'enGB.toString() returns "en-GB"'); 20 21 // Pass Intl.Locale object and replace Unicode extension keyword. 22 const zhUnihan = new Intl.Locale("zh-u-co-unihan"); 23 const zhZhuyin = new Intl.Locale(zhUnihan, {collation: "zhuyin"}); 24 25 assert.sameValue( 26 zhUnihan.toString(), 27 "zh-u-co-unihan", 28 'zhUnihan.toString() returns "zh-u-co-unihan"' 29 ); 30 assert.sameValue( 31 zhZhuyin.toString(), 32 "zh-u-co-zhuyin", 33 'zhZhuyin.toString() returns "zh-u-co-zhuyin"' 34 ); 35 36 assert.sameValue(zhUnihan.collation, "unihan", 'The value of zhUnihan.collation is "unihan"'); 37 assert.sameValue(zhZhuyin.collation, "zhuyin", 'The value of zhZhuyin.collation is "zhuyin"'); 38 39 reportCompare(0, 0);