summaryrefslogtreecommitdiff
path: root/deps/v8/test/intl/regress-8432.js
blob: 13083e3c821fe62956f8dec7c79be6f4e68f2696 (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
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Somehow only ar-SA fails on Android in regress-8413*.js.
// Split it into this test just for ar-SA.
// This is likely to be caused by an Android-specific ICU data trimming.
let locales = [ "ar-SA" ];

// "Table 5: Components of date and time formats" as in
// https://ecma-international.org/ecma-402/#sec-datetimeformat-abstracts
let table5 = [
  ["weekday", ["narrow", "short", "long"]],
  ["era", ["narrow", "short", "long"]],
  ["year", ["2-digit", "numeric"]],
  ["month", ["2-digit", "numeric", "narrow", "short", "long"]],
  ["day", ["2-digit", "numeric"]],
  ["hour", ["2-digit", "numeric"]],
  ["minute", ["2-digit", "numeric"]],
  ["second", ["2-digit", "numeric"]],
  ["timeZoneName", ["short", "long"]]
];

// Test each locale
for (let loc of locales) {
  // Test each property in Table 5
  for (let row of table5) {
    let prop = row[0];
    let values = row[1];
    // Test each value of the property
    for (let value of values) {
      let opt = {};
      opt[prop] = value;
      let dft = new Intl.DateTimeFormat([loc], opt);
      let result = dft.resolvedOptions();
      assertTrue(values.indexOf(result[prop]) >= 0,
          "Expect new Intl.DateTimeFormat([" + loc + "], {" + prop + ": '" +
          value + "'}).resolvedOptions()['" + prop + "'] to return one of [" +
          values + "] but got '" + result[prop] + "'");
    }
  }
}