Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * @description Tests that language tags with "_" are not accepted.
6 * @author Norbert Lindenberg
7 */
9 $INCLUDE("testIntl.js");
11 var invalidLanguageTags = [
12 "de_DE",
13 "DE_de",
14 "cmn_Hans",
15 "cmn-hans_cn",
16 "es_419",
17 "es-419-u-nu-latn-cu_bob",
18 "i_klingon",
19 "cmn-hans-cn-t-ca-u-ca-x_t-u",
20 "enochian_enochian",
21 "de-gregory_u-ca-gregory"
22 ];
24 testWithIntlConstructors(function (Constructor) {
25 invalidLanguageTags.forEach(function (tag) {
26 var error;
27 try {
28 // this must throw an exception for an invalid language tag
29 var obj = new Constructor([tag]);
30 } catch (e) {
31 error = e;
32 }
33 if (error === undefined) {
34 $ERROR("Invalid language tag " + tag + " was not rejected.");
35 } else if (error.name !== "RangeError") {
36 $ERROR("Invalid language tag " + tag + " was rejected with wrong error " + error.name + ".");
37 }
38 });
39 return true;
40 });