-
Notifications
You must be signed in to change notification settings - Fork 396
Add remaining j.u.function interfaces #4365
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
Conversation
javalib/src/main/scala/java/util/function/LongUnaryOperator.scala
Outdated
Show resolved
Hide resolved
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.
Thanks for the PR.
All of those new interfaces should have tests in https://github.com/scala-js/scala-js/tree/master/test-suite/shared/src/test/scala/org/scalajs/testsuite/javalib/util/function. There are already tests for the existing JDK function types in that directory, that you can take inspiration from.
dbbde57
to
6140951
Compare
This PR is ready to get reviewed |
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.
Only minor comments. When changing self
to this
, make sure you don't forget to remove the self types (self =>
) as well.
...hared/src/test/scala/org/scalajs/testsuite/javalib/util/function/IntBinaryOperatorTest.scala
Outdated
Show resolved
Hide resolved
val f = new IntToDoubleFunction { | ||
override def applyAsDouble(value: Int): Double = value.toDouble / 11d | ||
} | ||
assertEquals(f.applyAsDouble(3), 0.272, 0.001) |
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.
Take something that rounds properly so you don' need the epsilon?
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.
Or just use the full result.
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.
I think epsilon is needed since JUnit deprecated assertEquals(double expected, double actual)
and encourage to use assertEquals(double expected, double actual, double delta)
.
https://junit.org/junit4/javadoc/4.12/org/junit/Assert.html#assertEquals(double,%20double)
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.
Yes but we can use a 0.0
value for the epsilon. We often do that.
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.
Fixed: 5122020
...shared/src/test/scala/org/scalajs/testsuite/javalib/util/function/IntUnaryOperatorTest.scala
Outdated
Show resolved
Hide resolved
...shared/src/test/scala/org/scalajs/testsuite/javalib/util/function/ToLongBiFunctionTest.scala
Outdated
Show resolved
Hide resolved
Note that the consumer tests do not test exception behavior. IMO this is OK, given how simple the implementation is. @sjrd opinions? |
Should be fine. |
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.
Just the epsilon thing. Otherwise LG.
Feel free to squash.
Re commit message: In the body, you might want to write something like:
Fix #4227, fix #4228, and fix #4229
so it actually closes all the issues (but its not super important).
@gzm0 Commits were squashed. |
Oh sorry. Maybe that wasn't clear. I meant the fix stuff should go into the body not the subject. Like this it is very hard to read the commit subject. |
@sjrd any further input / requests? |
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.
No. It's all good :)
Closes #4227, #4228, and #4229