Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/intl402/Intl/getCanonicalLocales/error-cases.js

raw
1 // Copyright 2016 Mozilla Corporation. All rights reserved.
2 // This code is governed by the license found in the LICENSE file.
3
4 /*---
5 esid: sec-intl.getcanonicallocales
6 description: Tests the getCanonicalLocales function for error tags.
7 info: |
8 8.2.1 Intl.getCanonicalLocales (locales)
9 1. Let ll be ? CanonicalizeLocaleList(locales).
10 2. Return CreateArrayFromList(ll).
11 includes: [compareArray.js]
12 features: [Symbol]
13 ---*/
14
15 var rangeErrorCases =
16 [
17 "en-us-",
18 "-en-us",
19 "en-us-en-us",
20 "--",
21 "-",
22 "",
23 "-e-"
24 ];
25
26 rangeErrorCases.forEach(function(re) {
27 assert.throws(RangeError, function() {
28 Intl.getCanonicalLocales(re);
29 });
30 });
31
32 var typeErrorCases =
33 [
34 null,
35 [null],
36 [undefined],
37 [true],
38 [NaN],
39 [2],
40 [Symbol('foo')]
41 ];
42
43 typeErrorCases.forEach(function(te) {
44 assert.throws(TypeError, function() {
45 Intl.getCanonicalLocales(te);
46 });
47 });