8000 Add remaining j.u.function interfaces by exoego · Pull Request #4365 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Mar 16, 2021
Merged

Conversation

exoego
Copy link
Contributor
@exoego exoego commented Jan 7, 2021

Closes #4227, #4228, and #4229

Copy link
Member
@sjrd sjrd left a 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.

@exoego
Copy link
Contributor Author
exoego commented Mar 15, 2021

This PR is ready to get reviewed

@sjrd sjrd self-requested a review March 15, 2021 03:58
Copy link
Contributor
@gzm0 gzm0 left a 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.

val f = new IntToDoubleFunction {
override def applyAsDouble(value: Int): Double = value.toDouble / 11d
}
assertEquals(f.applyAsDouble(3), 0.272, 0.001)
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author
@exoego exoego Mar 16, 2021

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)

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: 5122020

@gzm0
Copy link
Contributor
gzm0 commented Mar 15, 2021

Note that the consumer tests do not test exception behavior. IMO this is OK, given how simple the implementation is. @sjrd opinions?

@sjrd
Copy link
Member
sjrd commented Mar 15, 2021

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.

Copy link
Contributor
@gzm0 gzm0 left a 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).

@exoego
Copy link
Contributor Author
exoego commented Mar 16, 2021

@gzm0 Commits were squashed.

@gzm0
Copy link
Contributor
gzm0 commented Mar 16, 2021

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.

< 8000 /div>
@exoego
Copy link
Contributor Author
exoego commented Mar 16, 2021

@gzm0 Do you mean this ? cfb4888

@gzm0
Copy link
Contributor
gzm0 commented Mar 16, 2021

@sjrd any further input / requests?

Copy link
Member
@sjrd sjrd left a 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 :)

@sjrd sjrd merged commit d09ce38 into scala-js:master Mar 16, 2021
@exoego exoego deleted the java-functions branch March 16, 2021 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants
0