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: Reorganize calendar and wrong-type tests #4415

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

brageh01
Copy link

@brageh01 brageh01 commented Mar 4, 2025

Changes made to:

  • PlainDate
  • PlainYearMonth
  • ZonedDateTime
  • PlainDateTime
  • PlainMonthDay

Merged calendar-number.js and calendar-wrong-type.js, due to no special behaviour of number to be tested.

Extracted string tests to calendar-iso-string.js and renamed the file to calendar-invalid-iso-string.js, due to the contents of the file initially testing invalid ISO strings.

Questions:

Are change to be made for the argument-propertybag-calendar-number.js and argument-propertybag-calendar-wrong-type.js files as well?
However, I notice that the argument-propertybag-calendar-iso-string.js actually tests for valid and not invalid ISO strings here. Perhaps create a invalid-iso-string.js?

Is the "merge-and-extract» also relevant for relativeto-propertybag-calendar-number.js and relativeto-propertybag-calendar-wrong-type.js?

@brageh01 brageh01 requested a review from a team as a code owner March 4, 2025 11:32
@brageh01 brageh01 changed the title Reorganize calendar and wrong-type tests Temporal: Reorganize calendar and wrong-type tests Mar 5, 2025
@sffc
Copy link
Contributor

sffc commented Mar 5, 2025

Issue: #3873

@sffc
Copy link
Contributor

sffc commented Mar 5, 2025

About the questions: my sense is that the propertybag tests are probably also in scope to be refactored here in a similar way.

Brage Hogstad and others added 9 commits March 11, 2025 13:50
…ring test into a separate file for relativeto-propertybag
…de; missing newline
@brageh01 brageh01 marked this pull request as draft March 11, 2025 14:07
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! It looks like this is on the right track. There may be some tests still left to do. For example, there should be relativeto-propertybag-... tests in Duration/prototype/round/ and Duration/compare/ as well, and I think there are a lot more argument-propertybag-... tests; there should be some for every API entry point that takes a Temporal object, for example withPlainTime methods.

Feel free to use a script to automate a first draft of changes if there are a lot of files to do.

To answer your questions:

Are change to be made for the argument-propertybag-calendar-number.js and argument-propertybag-calendar-wrong-type.js files as well?

Yes please.

However, I notice that the argument-propertybag-calendar-iso-string.js actually tests for valid and not invalid ISO strings here. Perhaps create a invalid-iso-string.js?

That sounds correct.

Is the "merge-and-extract» also relevant for relativeto-propertybag-calendar-number.js and relativeto-propertybag-calendar-wrong-type.js?

Yes.

@@ -9,20 +9,23 @@ description: >
features: [BigInt, Symbol, Temporal]
---*/

const timeZone = "UTC";
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you found a pre-existing error in this test, we forgot the time zone. Thanks!

(Well, technically it's not an error; in step 4.b-c of ToTemporalZonedDateTime the check for a faulty calendar occurs before the check for a missing time zone. So the test was still correct, but it was testing something different than I expected.)

Normally I would suggest that we should make a separate test file to ensure that the "faulty calendar" exception is thrown before the "missing time zone" exception, but in this case I think no further action is needed. We generally don't test that sort of thing anyway currently. (See also #2746 for a draft of how we might test it in the future.)

@ptomato
Copy link
Contributor

ptomato commented Mar 12, 2025

One more thing I forgot... please take a look at the indentation. We don't generally enforce particular coding style or indentation choices, but there are some files in this draft where the indentation is a mix of 2 and 4 spaces and we should try to avoid that.

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.

None yet

3 participants