summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Locale/constructor-options-script-invalid.js
blob: 01141210d5decbb5f1b9feb45f90a67a7a3f4039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2018 André Bargull; Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.locale
description: >
    Checks error cases for the options argument to the Locale
    constructor.
info: |
    Intl.Locale( tag [, options] )
    10. If options is undefined, then
    11. Else
        a. Let options be ? ToObject(options).
    12. Set tag to ? ApplyOptionsToTag(tag, options).

    ApplyOptionsToTag( tag, options )
    ...
    6. If script is not undefined, then
        a. If script does not match the script production, throw a RangeError exception.
    ...

features: [Intl.Locale]
---*/

/*
 script        = 4ALPHA              ; ISO 15924 code
*/
const invalidScriptOptions = [
  "",
  "a",
  "ab",
  "abc",
  "abc7",
  "notascript",
  "undefined",
  "Bal\u0130",
  "Bal\u0131",

  // Value contains more than just the 'script' production.
  "ary-Arab",
  "Latn-SA",
  "Latn-vaidika",
  "Latn-a-asdf",
  "Latn-x-private",

  7,
];
for (const script of invalidScriptOptions) {
  assert.throws(RangeError, function() {
    new Intl.Locale("en", {script});
  }, `new Intl.Locale("en", {script: "${script}"}) throws RangeError`);
}

reportCompare(0, 0);