summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js')
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js
new file mode 100644
index 0000000000..1ead004463
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/overflow-undefined.js
@@ -0,0 +1,48 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainyearmonth.from
+description: Fallback value for overflow option
+info: |
+ sec-getoption step 3:
+ 3. If _value_ is *undefined*, return _fallback_.
+ sec-temporal-totemporaloverflow step 1:
+ 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
+ sec-temporal-totemporalyearmonth steps 2–3:
+ 2. If Type(_item_) is Object, then
+ ...
+ e. Return ? YearMonthFromFields(_calendar_, _fields_, _options_).
+ 3. Perform ? ToTemporalOverflow(_options_).
+ sec-temporal.plainyearmonth.from steps 2–3:
+ 2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalYearMonth]] internal slot, then
+ a. Perform ? ToTemporalOverflow(_options_).
+ b. Return ...
+ 3. Return ? ToTemporalYearMonth(_item_, _options_).
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const validValues = [
+ new Temporal.PlainYearMonth(2000, 5),
+ "2000-05",
+];
+validValues.forEach((value) => {
+ const explicit = Temporal.PlainYearMonth.from(value, { overflow: undefined });
+ TemporalHelpers.assertPlainYearMonth(explicit, 2000, 5, "M05", "overflow is ignored");
+ const implicit = Temporal.PlainYearMonth.from(value, {});
+ TemporalHelpers.assertPlainYearMonth(implicit, 2000, 5, "M05", "overflow is ignored");
+ const lambda = Temporal.PlainYearMonth.from(value, () => {});
+ TemporalHelpers.assertPlainYearMonth(lambda, 2000, 5, "M05", "overflow is ignored");
+});
+
+const propertyBag = { year: 2000, month: 13 };
+const explicit = Temporal.PlainYearMonth.from(propertyBag, { overflow: undefined });
+TemporalHelpers.assertPlainYearMonth(explicit, 2000, 12, "M12", "default overflow is constrain");
+const implicit = Temporal.PlainYearMonth.from(propertyBag, {});
+TemporalHelpers.assertPlainYearMonth(implicit, 2000, 12, "M12", "default overflow is constrain");
+const lambda = Temporal.PlainYearMonth.from(propertyBag, () => {});
+TemporalHelpers.assertPlainYearMonth(lambda, 2000, 12, "M12", "default overflow is constrain");
+
+reportCompare(0, 0);