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 assertion message formatting #3991

Merged
merged 2 commits into from
Jan 22, 2024
Merged

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Jan 19, 2024

Some improvements to the formatting of assertion messages for the various Temporal types. This should make assertion failures easier to understand.

@ptomato ptomato requested a review from a team as a code owner January 19, 2024 22:38
@@ -101,7 +103,7 @@ var TemporalHelpers = {
* the corresponding field in another Temporal.Duration.
*/
assertDurationsEqual(actual, expected, description = "") {
assert(expected instanceof Temporal.Duration, `${description} expected value should be a Temporal.Duration`);
assert(expected instanceof Temporal.Duration, `${description}: expected value should be a Temporal.Duration`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not do the prefix dance here? Also e.g. assertInstantsEqual

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that. I think I just overlooked them.

Adding colons in the appropriate places will make assertion failures
easier to understand.
We stored Temporal.PlainDateTime.compare in a variable for convenience but
then used Temporal.PlainDate.compare instead. The variable was actually
intended to be used here. No change in functionality.
@ptomato ptomato merged commit 97a2e44 into tc39:main Jan 22, 2024
9 checks passed
@ptomato ptomato deleted the temporal-formatting branch January 22, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants