tor-browser

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

constructor-options-firstDayOfWeek-valid.js (2574B)


      1 // |reftest| skip -- Intl.Locale-info is not supported
      2 // Copyright 2023 Google Inc.  All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-intl.locale
      7 description: >
      8    Checks valid cases for the options argument to the Locale constructor.
      9 info: |
     10    Intl.Locale( tag [, options] )
     11 
     12    ...
     13    x. Let fw be ? GetOption(options, "firstDayOfWeek", "string", undefined, undefined).
     14    x. If fw is not undefined, then
     15       x. Set fw to !WeekdayToString(fw).
     16       x. If fw does not match the type sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a RangeError exception.
     17    x. Set opt.[[fw]] to fw.
     18    ...
     19    x. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
     20    ...
     21    x. Set locale.[[FirstDayOfWeek]] to r.[[fw]].
     22    ...
     23 
     24 features: [Intl.Locale,Intl.Locale-info]
     25 ---*/
     26 
     27 const validFirstDayOfWeekOptions = [
     28  ["mon", "en-u-fw-mon"],
     29  ["tue", "en-u-fw-tue"],
     30  ["wed", "en-u-fw-wed"],
     31  ["thu", "en-u-fw-thu"],
     32  ["fri", "en-u-fw-fri"],
     33  ["sat", "en-u-fw-sat"],
     34  ["sun", "en-u-fw-sun"],
     35  ["1", "en-u-fw-mon"],
     36  ["2", "en-u-fw-tue"],
     37  ["3", "en-u-fw-wed"],
     38  ["4", "en-u-fw-thu"],
     39  ["5", "en-u-fw-fri"],
     40  ["6", "en-u-fw-sat"],
     41  ["7", "en-u-fw-sun"],
     42  ["0", "en-u-fw-sun"],
     43  [1, "en-u-fw-mon"],
     44  [2, "en-u-fw-tue"],
     45  [3, "en-u-fw-wed"],
     46  [4, "en-u-fw-thu"],
     47  [5, "en-u-fw-fri"],
     48  [6, "en-u-fw-sat"],
     49  [7, "en-u-fw-sun"],
     50  [0, "en-u-fw-sun"],
     51  [true, "en-u-fw"],
     52  [false, "en-u-fw-false"],
     53  [null, "en-u-fw-null"],
     54  ["primidi", "en-u-fw-primidi"],
     55  ["duodi", "en-u-fw-duodi"],
     56  ["tridi", "en-u-fw-tridi"],
     57  ["quartidi", "en-u-fw-quartidi"],
     58  ["quintidi", "en-u-fw-quintidi"],
     59  ["sextidi", "en-u-fw-sextidi"],
     60  ["septidi", "en-u-fw-septidi"],
     61  ["octidi", "en-u-fw-octidi"],
     62  ["nonidi", "en-u-fw-nonidi"],
     63  ["decadi", "en-u-fw-decadi"],
     64  ["frank", "en-u-fw-frank"],
     65  ["yungfong", "en-u-fw-yungfong"],
     66  ["yung-fong", "en-u-fw-yung-fong"],
     67  ["tang", "en-u-fw-tang"],
     68  ["frank-yung-fong-tang", "en-u-fw-frank-yung-fong-tang"],
     69 ];
     70 for (const [firstDayOfWeek, expected] of validFirstDayOfWeekOptions) {
     71  assert.sameValue(
     72    new Intl.Locale('en', { firstDayOfWeek }).toString(),
     73    expected,
     74    `new Intl.Locale("en", { firstDayOfWeek: ${firstDayOfWeek} }).toString() returns "${expected}"`
     75  );
     76  assert.sameValue(
     77    new Intl.Locale('en-u-fw-WED', { firstDayOfWeek }).toString(),
     78    expected,
     79    `new Intl.Locale("en-u-fw-WED", { firstDayOfWeek: ${firstDayOfWeek} }).toString() returns "${expected}"`
     80  );
     81 }
     82 
     83 reportCompare(0, 0);