-
Notifications
You must be signed in to change notification settings - Fork 363
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 j.u.Collection.removeIf. #2013
Implement j.u.Collection.removeIf. #2013
Conversation
The test was ported from Scala.js by Lorenzo G (lolgab) as part of his PR scala-native#1994 and used with his kind permission. This PR is WIP because it will fail to build until after PR scala-native#2013 (Collection) and its series of prerequisites are merged and this PR re-based.
The test was ported from Scala.js by Lorenzo G (lolgab) as part of his PR scala-native#1994 and used with his kind permission. This PR is WIP because it will fail to build until after PR scala-native#2013 (Collection) and its series of prerequisites are merged and this PR re-based.
1e6aaf0
to
45c517d
Compare
// Issue: https://github.com/scala-native/scala-native/issues/1972 | ||
@Ignore( | ||
"removeIf is a JavaDefaultMethod which is not supported yet on Scala 2.11") | ||
@Test def removeIf(): Unit = { | ||
// val coll = factory.fromElements[Int](42, 50, 12, 0, -45, 102, 32, 75) | ||
// assertEquals(8, coll.size()) | ||
|
||
// assertTrue(coll.removeIf(new java.util.function.Predicate[Int] { | ||
// def test(x: Int): Boolean = x >= 50 | ||
// })) | ||
// assertEquals(5, coll.size()) | ||
// assertIteratorSameElementsAsSet(-45, 0, 12, 32, 42)(coll.iterator()) | ||
|
||
// assertFalse(coll.removeIf(new java.util.function.Predicate[Int] { | ||
// def test(x: Int): Boolean = x >= 45 | ||
// })) | ||
// assertEquals(5, coll.size()) | ||
// assertIteratorSameElementsAsSet(-45, 0, 12, 32, 42)(coll.iterator()) | ||
} |
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 you can now uncomment this test and remove the // Issue: ...
comment I added and the @Ignore
annotation. Take the original file as guide.
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.
Oops! Thank you for catching that. It is kind of one of the main motivators for the Test.
I had read your documentation about the ignore
and seen the code, but the message
never arrived to my fingers when I copied the code. Fix in process.
Is this still WiP? |
Thank you for looking at this. Yes, it is still WIP. For final testing, it depends upon the Iterable PR #2009 which This PR is passing, and I have tested using my private implementation of Iterable, |
I merged #2009. |
b7aa231
to
4080457
Compare
Sjrd. Thank you for the rapid merge of PR #2009 |
4080457
to
5f6bd8f
Compare
Re-based & re-built now that PR #2040 has been merged. CI is all green. |
import scala.scalanative.junit.utils.AssertThrows._ | ||
import scala.scalanative.junit.utils.Utils._ | ||
|
||
trait CollectionTest extends IterableTest { |
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.
This file on its own is all dead code. We would need at least one concrete subclass of CollectionTest
with a concrete factory type to make this non dead code.
So either CollectionTest
and TrivialImmutableCollection
should be removed from this PR (and instead introduced in a PR that actually has a least one concrete subclass), or we should add such a concrete subclass in this PR.
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 chose the second alternative and moved AbstractCollection.scala & AbstractCollectionTest.scala
from PR #2014. This keeps the two sets of file.scala & fileTest.scala in the same PR.
AbstractCollectionTest implements the concrete subclass.
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.
PS: thank you for clearly describing the alternatives.
This PR builds upon merged PR scala-native#1937 by porting Collection.scala and its corresponding test from Scala.js. The test was ported from Scala.js by Lorenzo G (lolgab) as part of his PR scala-native#1994. See Issue scala-native#1972 for background & discussion of JavaDefaultMethod annotation. This PR is WIP because it will fail to build until after PR scala-native#1997 (nscplugin), scala-native#2009 (j.l.Iterable), & 2010 (TrivialCollection) are merged and this PR is re-based.
5f6bd8f
to
e72e2ff
Compare
We test it through `AbstractCollection`, which we update as well. Ported from Scala.js.
We test it through `AbstractCollection`, which we update as well. Ported from Scala.js.
This PR builds upon merged PRs #1937 & #2040 by re-porting Collection.scala and
AbstractCollection.scala from Scala.js.
The corresponding tests and TrivialImmutableCollection.scala were freshly ported from Scala.js by
Lorenzo G (lolgab) as part of his PR #1994 and are used by his kind permission.
Collection.scala provides the default methods. AbstractCollectionTest provides a concrete
factory type which exercises the methods of both Collection.scala & AbstractCollection.scala.