2012-08-27 05:50:24 +02:00
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
2014-07-22 01:09:02 +02:00
/ * - - -
2014-07-25 00:41:42 +02:00
es5id : 10.1 . 1_19_ b
2014-07-22 01:09:02 +02:00
description : Tests the special handling of the "co" key in Intl . Collator .
author : Norbert Lindenberg
-- - * /
2012-08-27 05:50:24 +02:00
function checkCollation ( extensionCoValue , usageValue , expectedCollations , expectedUsage ) {
var requestLocale = extensionCoValue !== undefined ? "de-DE-u-co-" + extensionCoValue : "de-DE" ;
var options = usageValue !== undefined ? { usage : usageValue } : undefined ;
var collator = new Intl . Collator ( [ requestLocale ] , options ) ;
var collation = collator . resolvedOptions ( ) . collation ;
2017-05-04 21:10:58 +02:00
assert . notSameValue ( expectedCollations . indexOf ( collation ) , - 1 , ( extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue ) + "\" should be " + expectedCollations . join ( " or " ) + ", but is " + collation + "." ) ;
2012-08-27 05:50:24 +02:00
var usage = collator . resolvedOptions ( ) . usage ;
2017-05-04 21:10:58 +02:00
assert . sameValue ( usage , expectedUsage , ( usageValue === undefined ? "Default usage" : "Usage" ) + " mismatch." ) ;
2012-08-27 05:50:24 +02:00
}
checkCollation ( undefined , undefined , [ "default" ] , "sort" ) ;
checkCollation ( "phonebk" , undefined , [ "phonebk" , "default" ] , "sort" ) ;
checkCollation ( "invalid" , undefined , [ "default" ] , "sort" ) ;
checkCollation ( "standard" , undefined , [ "default" ] , "sort" ) ;
checkCollation ( "standard" , "search" , [ "default" ] , "search" ) ;
checkCollation ( "standard" , "sort" , [ "default" ] , "sort" ) ;
checkCollation ( "search" , undefined , [ "default" ] , "sort" ) ;
checkCollation ( "search" , "search" , [ "default" ] , "search" ) ;
checkCollation ( "search" , "sort" , [ "default" ] , "sort" ) ;