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

Use a fixed DateTime in rounding tests instead of now() #37528

Merged
merged 2 commits into from
Sep 11, 2020
Merged

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Sep 11, 2020

Using now led to inconsistent answers depending on when now() is; make
tests more reliable by using a fixed DateTime.

Using now led to inconsistent answers depending on when `now()` is; make
tests more reliable by using a fixed `DateTime`.
@Moelf
Copy link
Sponsor Contributor

Moelf commented Sep 11, 2020

but now() was only accessed once, tests failing means there were unexpected behavior (which user will face too) right?

@simeonschaub
Copy link
Member

I can't say much about whether the test failures actually represent a problem in the implementation, but it generally seems like a bad idea for tests to depend on the current time.

@Moelf
Copy link
Sponsor Contributor

Moelf commented Sep 11, 2020

I agree but in this case it seems there exist a Time where round(Date, now_, p, r) did something different than first convert now_ to Date(now_) and then do rounding -- which is strictly what user would expect.

@quinnj
Copy link
Member Author

quinnj commented Sep 11, 2020

Valid concerns; I dug in a bit further and discovered we were passing the wrong default rounding mode to round, which is RoundNearestTiesUp, but we were passing RoundUp, which led to the test failures. I've pushed the fix here.

@Moelf
Copy link
Sponsor Contributor

Moelf commented Sep 11, 2020

thanks! I must missed that bit

@quinnj quinnj merged commit 7ecd1f9 into master Sep 11, 2020
@quinnj quinnj deleted the jq/dtroundfix branch September 11, 2020 18:19
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