Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporal: Add test for balancing up to weeks when year/month are present #4305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

catamorphism
Copy link
Contributor

@catamorphism catamorphism requested a review from a team as a code owner November 4, 2024 21:39
Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -0,0 +1,52 @@
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test, so

Suggested change
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
// Copyright (C) 2024 Igalia, S.L. All rights reserved.


/*---
esid: sec-temporal.duration.prototype.round
description: Balances up to weeks correctly when years and months are present.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick about the terminology:

Suggested change
description: Balances up to weeks correctly when years and months are present.
description: Rounds up to weeks correctly when years and months are present.

I'd suggest renaming the test file as well.

(Rounding is when the duration is modified, balancing is when the duration remains the same length but is expressed in different units)

---*/

const oneMonthOneDay = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0);
const oneYearOneMonthOneDay = new Temporal.Duration(1, 1, 0, 1, 0, 0, 0, 0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest something like

const relativeTo = new Temporal.PlainDate(2024, 1, 1);

and using that in the options bags throughout.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I've been looking at the existing tests in round/ and I think we might not have coverage of rounding a duration with only days up to weeks. So maybe add something like

const severalWeeksInDays = new Temporal.Duration(0, 0, 0, 29, 0, 0, 0, 0, 0, 0);

(I might have missed it if we already had coverage of this, though! There are a lot of tests in this folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants