Basic tests for PlainDate#{add,subtract}.

This commit is contained in:
Ms2ger 2022-01-24 11:41:43 +01:00 committed by Rick Waldron
parent f768a24ab6
commit 4eb14032ae
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.add
description: Basic tests
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const date = Temporal.PlainDate.from("1976-11-18");
TemporalHelpers.assertPlainDate(date.add({ years: 43 }),
2019, 11, "M11", 18);
TemporalHelpers.assertPlainDate(date.add({ months: 3 }),
1977, 2, "M02", 18);
TemporalHelpers.assertPlainDate(date.add({ days: 20 }),
1976, 12, "M12", 8);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from("2019-01-31").add({ months: 1 }),
2019, 2, "M02", 28);
TemporalHelpers.assertPlainDate(date.add(Temporal.Duration.from('P43Y')),
2019, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-11-18').add({ years: -43 }),
1976, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('1977-02-18').add({ months: -3 }),
1976, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('1976-12-08').add({ days: -20 }),
1976, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-02-28').add({ months: -1 }),
2019, 1, "M01", 28);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindate.prototype.subtract
description: Basic tests
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const date = Temporal.PlainDate.from("2019-11-18");
TemporalHelpers.assertPlainDate(date.subtract({ years: 43 }),
1976, 11, "M11", 18);
TemporalHelpers.assertPlainDate(date.subtract({ months: 11 }),
2018, 12, "M12", 18);
TemporalHelpers.assertPlainDate(date.subtract({ days: 20 }),
2019, 10, "M10", 29);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-02-28').subtract({ months: 1 }),
2019, 1, "M01", 28);
TemporalHelpers.assertPlainDate(date.subtract(Temporal.Duration.from('P43Y')),
1976, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('1976-11-18').subtract({ years: -43 }),
2019, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2018-12-18').subtract({ months: -11 }),
2019, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-10-29').subtract({ days: -20 }),
2019, 11, "M11", 18);
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-01-28').subtract({ months: -1 }),
2019, 2, "M02", 28);