1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/intl402/ch10/10.1/10.1.1_19_b.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +// Copyright 2012 Mozilla Corporation. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * @description Tests the special handling of the "co" key in Intl.Collator. 1.9 + * @author Norbert Lindenberg 1.10 + */ 1.11 + 1.12 +function checkCollation(extensionCoValue, usageValue, expectedCollations, expectedUsage) { 1.13 + var requestLocale = extensionCoValue !== undefined ? "de-DE-u-co-" + extensionCoValue : "de-DE"; 1.14 + var options = usageValue !== undefined ? { usage: usageValue } : undefined; 1.15 + var collator = new Intl.Collator([requestLocale], options); 1.16 + 1.17 + var collation = collator.resolvedOptions().collation; 1.18 + if (expectedCollations.indexOf(collation) === -1) { 1.19 + $ERROR((extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) + 1.20 + "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + "."); 1.21 + } 1.22 + 1.23 + var usage = collator.resolvedOptions().usage; 1.24 + if (expectedUsage !== usage) { 1.25 + $ERROR((usageValue === undefined ? "Default usage" : "Usage") + 1.26 + " should be " + expectedUsage + ", but is " + usage + "."); 1.27 + } 1.28 +} 1.29 + 1.30 +checkCollation(undefined, undefined, ["default"], "sort"); 1.31 + 1.32 +checkCollation("phonebk", undefined, ["phonebk", "default"], "sort"); 1.33 + 1.34 +checkCollation("invalid", undefined, ["default"], "sort"); 1.35 + 1.36 +checkCollation("standard", undefined, ["default"], "sort"); 1.37 + 1.38 +checkCollation("standard", "search", ["default"], "search"); 1.39 + 1.40 +checkCollation("standard", "sort", ["default"], "sort"); 1.41 + 1.42 +checkCollation("search", undefined, ["default"], "sort"); 1.43 + 1.44 +checkCollation("search", "search", ["default"], "search"); 1.45 + 1.46 +checkCollation("search", "sort", ["default"], "sort"); 1.47 +