constructor-options-numberingsystem-valid.js (2216B)
1 // Copyright 2018 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 Checks valid cases for the options argument to the Locale constructor. 8 info: | 9 Intl.Locale( tag [, options] ) 10 11 ... 12 27. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined). 13 ... 14 29. Set opt.[[nu]] to numberingSystem. 15 ... 16 30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys). 17 ... 18 19 ApplyUnicodeExtensionToTag( tag, options, relevantExtensionKeys ) 20 21 ... 22 8. Let locale be the String value that is tag with all Unicode locale extension sequences removed. 23 9. Let newExtension be ! CanonicalizeUnicodeExtension(attributes, keywords). 24 10. If newExtension is not the empty String, then 25 a. Let locale be ! InsertUnicodeExtension(locale, newExtension). 26 ... 27 28 CanonicalizeUnicodeExtension( attributes, keywords ) 29 ... 30 4. Repeat for each element entry of keywords in List order, 31 a. Let keyword be entry.[[Key]]. 32 b. If entry.[[Value]] is not the empty String, then 33 i. Let keyword be the string-concatenation of keyword, "-", and entry.[[Value]]. 34 c. Append keyword to fullKeywords. 35 ... 36 features: [Intl.Locale] 37 ---*/ 38 39 const validNumberingSystemOptions = [ 40 ["abc", "en-u-nu-abc"], 41 ["abcd", "en-u-nu-abcd"], 42 ["abcde", "en-u-nu-abcde"], 43 ["abcdef", "en-u-nu-abcdef"], 44 ["abcdefg", "en-u-nu-abcdefg"], 45 ["abcdefgh", "en-u-nu-abcdefgh"], 46 ["12345678", "en-u-nu-12345678"], 47 ["1234abcd", "en-u-nu-1234abcd"], 48 ["1234abcd-abc123", "en-u-nu-1234abcd-abc123"], 49 ]; 50 for (const [numberingSystem, expected] of validNumberingSystemOptions) { 51 assert.sameValue( 52 new Intl.Locale('en', { numberingSystem }).toString(), 53 expected, 54 `new Intl.Locale("en", { numberingSystem: ${numberingSystem} }).toString() returns "${expected}"` 55 ); 56 assert.sameValue( 57 new Intl.Locale('en-u-nu-latn', { numberingSystem }).toString(), 58 expected, 59 `new Intl.Locale("en-u-nu-latn", { numberingSystem: ${numberingSystem} }).toString() returns "${expected}"` 60 ); 61 } 62 63 reportCompare(0, 0);