js/src/tests/test262/intl402/ch06/6.4/6.4_b.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:effe5466dd9e
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 invalid time zone names are not accepted.
6 * @author Norbert Lindenberg
7 */
8
9 var invalidTimeZoneNames = [
10 "",
11 "MEZ", // localized abbreviation
12 "Pacific Time", // localized long form
13 "cnsha", // BCP 47 time zone code
14 "invalid", // as the name says
15 "Europe/İstanbul", // non-ASCII letter
16 "asıa/baku", // non-ASCII letter
17 "europe/brußels" // non-ASCII letter
18 ];
19
20 invalidTimeZoneNames.forEach(function (name) {
21 var error;
22 try {
23 // this must throw an exception for an invalid time zone name
24 var format = new Intl.DateTimeFormat(["de-de"], {timeZone: name});
25 } catch (e) {
26 error = e;
27 }
28 if (error === undefined) {
29 $ERROR("Invalid time zone name " + name + " was not rejected.");
30 } else if (error.name !== "RangeError") {
31 $ERROR("Invalid time zone name " + name + " was rejected with wrong error " + error.name + ".");
32 }
33 });
34

mercurial