unicode-ext-value-collation.js (1645B)
1 // Copyright 2012 Mozilla Corporation. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es5id: 10.1.1_19_b 6 description: Tests the special handling of the "co" key in Intl.Collator. 7 author: Norbert Lindenberg 8 ---*/ 9 10 function checkCollation(extensionCoValue, usageValue, expectedCollations, expectedUsage) { 11 var requestLocale = extensionCoValue !== undefined ? "de-DE-u-co-" + extensionCoValue : "de-DE"; 12 var options = usageValue !== undefined ? { usage: usageValue } : undefined; 13 var collator = new Intl.Collator([requestLocale], options); 14 15 var collation = collator.resolvedOptions().collation; 16 assert.notSameValue(expectedCollations.indexOf(collation), -1, (extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) + "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + "."); 17 18 var usage = collator.resolvedOptions().usage; 19 assert.sameValue(usage, expectedUsage, (usageValue === undefined ? "Default usage" : "Usage") + " mismatch."); 20 } 21 22 checkCollation(undefined, undefined, ["default"], "sort"); 23 24 checkCollation("phonebk", undefined, ["phonebk", "default"], "sort"); 25 26 checkCollation("invalid", undefined, ["default"], "sort"); 27 28 checkCollation("standard", undefined, ["default"], "sort"); 29 30 checkCollation("standard", "search", ["default"], "search"); 31 32 checkCollation("standard", "sort", ["default"], "sort"); 33 34 checkCollation("search", undefined, ["default"], "sort"); 35 36 checkCollation("search", "search", ["default"], "search"); 37 38 checkCollation("search", "sort", ["default"], "sort"); 39 40 reportCompare(0, 0);