tor-browser

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

overflow-undefined.js (2316B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-temporal.plainyearmonth.from
      7 description: Fallback value for overflow option
      8 info: |
      9    sec-getoption step 3:
     10      3. If _value_ is *undefined*, return _fallback_.
     11    sec-temporal-totemporaloverflow step 1:
     12      1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
     13    sec-temporal-totemporalyearmonth steps 2–3:
     14      2. If Type(_item_) is Object, then
     15        ...
     16        e. Return ? YearMonthFromFields(_calendar_, _fields_, _options_).
     17      3. Perform ? ToTemporalOverflow(_options_).
     18    sec-temporal.plainyearmonth.from steps 2–3:
     19      2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalYearMonth]] internal slot, then
     20        a. Perform ? ToTemporalOverflow(_options_).
     21        b. Return ...
     22      3. Return ? ToTemporalYearMonth(_item_, _options_).
     23 includes: [temporalHelpers.js]
     24 features: [Temporal]
     25 ---*/
     26 
     27 const validValues = [
     28  new Temporal.PlainYearMonth(2000, 5),
     29  "2000-05",
     30 ];
     31 validValues.forEach((value) => {
     32  const explicit = Temporal.PlainYearMonth.from(value, { overflow: undefined });
     33  TemporalHelpers.assertPlainYearMonth(explicit, 2000, 5, "M05", "overflow is ignored");
     34  const implicit = Temporal.PlainYearMonth.from(value, {});
     35  TemporalHelpers.assertPlainYearMonth(implicit, 2000, 5, "M05", "overflow is ignored");
     36  const lambda = Temporal.PlainYearMonth.from(value, () => {});
     37  TemporalHelpers.assertPlainYearMonth(lambda, 2000, 5, "M05", "overflow is ignored");
     38 });
     39 
     40 const propertyBag = { year: 2000, month: 13 };
     41 const explicit = Temporal.PlainYearMonth.from(propertyBag, { overflow: undefined });
     42 TemporalHelpers.assertPlainYearMonth(explicit, 2000, 12, "M12", "default overflow is constrain");
     43 const implicit = Temporal.PlainYearMonth.from(propertyBag, {});
     44 TemporalHelpers.assertPlainYearMonth(implicit, 2000, 12, "M12", "default overflow is constrain");
     45 const lambda = Temporal.PlainYearMonth.from(propertyBag, () => {});
     46 TemporalHelpers.assertPlainYearMonth(lambda, 2000, 12, "M12", "default overflow is constrain");
     47 
     48 reportCompare(0, 0);