js/src/tests/test262/intl402/ch09/9.2/9.2.8_1_c.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/intl402/ch09/9.2/9.2.8_1_c.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     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 that the option localeMatcher is processed correctly.
     1.9 + * @author Norbert Lindenberg
    1.10 + */
    1.11 +
    1.12 +$INCLUDE("testIntl.js");
    1.13 +
    1.14 +testWithIntlConstructors(function (Constructor) {
    1.15 +    var defaultLocale = new Constructor().resolvedOptions().locale;
    1.16 +    
    1.17 +    var validValues = [undefined, "lookup", "best fit", {toString: function () { return "lookup"; }}];
    1.18 +    validValues.forEach(function (value) {
    1.19 +        var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value});
    1.20 +    });
    1.21 +    
    1.22 +    var invalidValues = [null, 0, 5, NaN, true, false, "invalid"];
    1.23 +    invalidValues.forEach(function (value) {
    1.24 +        var error;
    1.25 +        try {
    1.26 +            var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value});
    1.27 +        } catch (e) {
    1.28 +            error = e;
    1.29 +        }
    1.30 +        if (error === undefined) {
    1.31 +            $ERROR("Invalid localeMatcher value " + value + " was not rejected.");
    1.32 +        } else if (error.name !== "RangeError") {
    1.33 +            $ERROR("Invalid localeMatcher value " + value + " was rejected with wrong error " + error.name + ".");
    1.34 +        }
    1.35 +    });
    1.36 +    
    1.37 +    return true;
    1.38 +});
    1.39 +

mercurial