tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

constructor-options-order-dayPeriod.js (1458B)


      1 // Copyright 2019 Googe Inc. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-createdatetimeformat
      6 description: Checks the order of getting options of 'dayPeriod' for the DateTimeFormat constructor.
      7 info: |
      8  CreateDateTimeFormat ( newTarget, locales, options, required, defaults )
      9  ...
     10  36. For each row of Table 7, except the header row, in table order, do
     11    a. Let prop be the name given in the Property column of the row.
     12    b. If prop is "fractionalSecondDigits", then
     13      i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined).
     14    c. Else,
     15      i. Let values be a List whose elements are the strings given in the Values column of the row.
     16      ii. Let value be ? GetOption(options, prop, string, values, undefined).
     17    d. Set formatOptions.[[<prop>]] to value.
     18  ...
     19 includes: [compareArray.js]
     20 features: [Intl.DateTimeFormat-dayPeriod]
     21 
     22 ---*/
     23 
     24 // Just need to ensure dayPeriod are get between day and hour.
     25 const expected = [
     26  // CreateDateTimeFormat step 36.
     27  "day",
     28  "dayPeriod",
     29  "hour"
     30 ];
     31 
     32 const actual = [];
     33 
     34 const options = {
     35  get day() {
     36    actual.push("day");
     37    return "numeric";
     38  },
     39  get dayPeriod() {
     40    actual.push("dayPeriod");
     41    return "long";
     42  },
     43  get hour() {
     44    actual.push("hour");
     45    return "numeric";
     46  },
     47 };
     48 
     49 new Intl.DateTimeFormat("en", options);
     50 assert.compareArray(actual, expected);
     51 
     52 reportCompare(0, 0);