-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Add float.modulo #582
Add float.modulo #582
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,6 +371,29 @@ pub fn random_test() { | |
|> should.be_true | ||
} | ||
|
||
pub fn modulo_test() { | ||
float.modulo(3.0, 2.0) | ||
|> should.equal(Ok(1.0)) | ||
|
||
float.modulo(1.0, 0.0) | ||
|> should.equal(Error(Nil)) | ||
|
||
float.modulo(10.0, -1.0) | ||
|> should.equal(Ok(0.0)) | ||
|
||
float.modulo(13.0, by: 3.0) | ||
|> should.equal(Ok(1.0)) | ||
|
||
float.modulo(-13.0, by: 3.0) | ||
|> should.equal(Ok(2.0)) | ||
|
||
float.modulo(13.0, by: -3.0) | ||
|> should.equal(Ok(-2.0)) | ||
|
||
float.modulo(-13.0, by: -3.0) | ||
|> should.equal(Ok(-1.0)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these are whole numbers. Let's have tests for other numbers too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, could you help me solve this failing test?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But then I believe I would need to import the |
||
} | ||
|
||
pub fn divide_test() { | ||
float.divide(1.0, 1.0) | ||
|> should.equal(Ok(1.0)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have fewer examples please? It's a little overwhelming I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments were copied from the
int.modulo
function, they explain all the possible behaviours.Can we keep the examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is too much information here, please reduce it. The examples section is not suitable for an exhaustive description of the behaviour.