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

Implement multipleOf #29

Merged
merged 6 commits into from
Feb 10, 2020
Merged

Implement multipleOf #29

merged 6 commits into from
Feb 10, 2020

Conversation

lexidor
Copy link
Contributor

@lexidor lexidor commented Jan 27, 2020

To quote John F. Kennedy

We do these things not because They Are easy hard, but because they are hard easy.

Partially addresses #7

@lexidor
Copy link
Contributor Author

lexidor commented Jan 27, 2020

Test failures are introduced in hhvm 4.0. I'll use alternatives that do work.

lexidor and others added 4 commits January 28, 2020 00:18
HHVM 4.0 does not allow reading from unknown fields using `??`
This was acutally a correct check
This saves us from the bug where someone does `"multipleOf": "cow"`
$remainer = Math\abs(
$dividend is int && $devisor is int ? $dividend % $devisor : \fmod((float)$dividend, (float)$devisor),
);
\var_dump(dict[

Choose a reason for hiding this comment

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

Not sure if you're still working on this, but we'll want to take this out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The var_dump() was for debugging purposes.
Will be I'll remove it.

use namespace HH\Lib\Math;
use namespace Slack\Hack\JsonSchema;

const float COMPARISON_LEEWAY = 10. ** -6;

Choose a reason for hiding this comment

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

Can we add a comment about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do.

throw new JsonSchema\InvalidFieldException($pointer, vec[$error]);
}
if ($remainer is float) {
if ($remainer < $devisor / 2 && $remainer > COMPARISON_LEEWAY) {

Choose a reason for hiding this comment

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

Would be good to have a comment about this logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that is a good plan.

@lexidor lexidor requested a review from mwildehahn February 8, 2020 17:45
Copy link

@mwildehahn mwildehahn left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you!

@mwildehahn mwildehahn merged commit 04b77ea into slackhq:master Feb 10, 2020
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