js/src/tests/test262/intl402/ch06/6.2/6.2.2_b.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:d78f57a60537
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 * @description Tests that language tags with "_" are not accepted.
6 * @author Norbert Lindenberg
7 */
8
9 $INCLUDE("testIntl.js");
10
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 ];
23
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 });
41

mercurial