d61809bb41
Land some of the tests for Temporal.PlainDate All marked as FAIL at this stage. Bug: v8:11544 Change-Id: I004b7cb34effe1de1735b61c7ac749ae3c8e9bf7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3085624 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#76551}
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
// Copyright 2021 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.
|
|
// Flags: --harmony-temporal
|
|
|
|
let d1 = Temporal.Now.plainDateISO();
|
|
// 1. Set options to ? GetOptionsObject(options).
|
|
[true, false, "string is invalid", Symbol(),
|
|
123, 456n, Infinity, NaN, null].forEach(function(invalidOptions) {
|
|
|
|
assertThrows(() => Temporal.PlainDate.from( d1, invalidOptions), TypeError);
|
|
});
|
|
|
|
// a. Perform ? ToTemporalOverflow(options).
|
|
assertThrows(() => Temporal.PlainDate.from(
|
|
d1, {overflow: "invalid overflow"}), RangeError);
|
|
|
|
[undefined, {}, {overflow: "constrain"}, {overflow: "reject"}].forEach(
|
|
function(validOptions) {
|
|
let d = new Temporal.PlainDate(1, 2, 3);
|
|
let d2 = Temporal.PlainDate.from(d, validOptions);
|
|
assertEquals(1, d2.year);
|
|
assertEquals(2, d2.month);
|
|
assertEquals(3, d2.day);
|
|
assertEquals("iso8601", d2.calendar.id);
|
|
});
|
|
|
|
[undefined, {}, {overflow: "constrain"}, {overflow: "reject"}].forEach(
|
|
function(validOptions) {
|
|
let d3 = Temporal.PlainDate.from( {year:9, month: 8, day:7}, validOptions);
|
|
assertEquals(9, d3.year);
|
|
assertEquals(8, d3.month);
|
|
assertEquals("M08", d3.monthCode);
|
|
assertEquals(7, d3.day);
|
|
assertEquals("iso8601", d3.calendar.id);
|
|
});
|
|
|
|
[undefined, {}, {overflow: "constrain"}].forEach(
|
|
function(validOptions) {
|
|
let d4 = Temporal.PlainDate.from( {year:9, month: 14, day:32}, validOptions);
|
|
assertEquals(9, d4.year);
|
|
assertEquals(12, d4.month);
|
|
assertEquals("M12", d4.monthCode);
|
|
assertEquals(31, d4.day);
|
|
assertEquals("iso8601", d4.calendar.id);
|
|
});
|
|
|
|
assertThrows(() => Temporal.PlainDate.from(
|
|
{year:9, month: 14, day:30}, {overflow: "reject"}), RangeError);
|
|
assertThrows(() => Temporal.PlainDate.from(
|
|
{year:9, month: 12, day:32}, {overflow: "reject"}), RangeError);
|