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

Update temporalHelpers.js #3861

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

justingrant
Copy link
Contributor

  • Fix SpecificOffsetTimeZone helper class so that it correctly implements the time zone protocol. Previously, some tests were passing but not actually exercising the expected codepaths.
  • Add assertDateDuration function, which makes it shorter to assert durations that only contain date components.

harness/temporalHelpers.js Outdated Show resolved Hide resolved
@justingrant justingrant force-pushed the fix-temporal-helpers branch 2 times, most recently from c766300 to 9f7d88a Compare July 1, 2023 21:17
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.

Fix SpecificOffsetTimeZone helper class so that it correctly implements the time zone protocol. Previously, some tests were passing but not actually exercising the expected codepaths.

I definitely intended the [] as a stub, because it hadn't been needed so far. Now that it's needed for the time zone offset tests, seems great to implement it 😄

Thanks!

getPossibleInstantsFor() {
return [];
getPossibleInstantsFor(dt) {
if (typeof this._offsetValue !== 'number' || Math.abs(this._offsetValue) >= 86400e9 || isNaN(this._offsetValue)) return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if any of these conditions are true, the test helper is being misused ... but I don't mind having this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly, I did it this way so that tests would fail in the right place in cases where the offset was invalid: either not a number or out of range. Otherwise, the failures would happen in the next line here in temporalHelpers, instead of actually exercising Temporal implementations' ability to reject invalid offset time zone IDs.

* Fix SpecificOffsetTimeZone so that it correctly implements the time
  zone protocol. Previously, tests were passing but not actually
  exercising the expected codepaths.
* Add assertDateDuration function, which makes it shorter to assert
  durations that only contain date components.
@ptomato ptomato merged commit 20e4420 into tc39:main Jul 11, 2023
1 check passed
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.

3 participants