diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-08-26 17:38:19 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-08-27 08:55:51 +0200 |
commit | 9276a1205f74fdec74206209712831913e93f359 (patch) | |
tree | 88b968bc84906bbfb75dbca60320449edc4fb050 /test | |
parent | 5e0880fe05fb65a8757721be7e5be6a3259c19a8 (diff) | |
download | scala-9276a1205f74fdec74206209712831913e93f359.tar.gz scala-9276a1205f74fdec74206209712831913e93f359.tar.bz2 scala-9276a1205f74fdec74206209712831913e93f359.zip |
SI-8627 make Stream.filterNot non-eager
The obvious fix, overriding `filterNot` in Stream, is not binary
compatible, see https://github.com/scala/scala/pull/3925
Instead, this makes `filterImpl` in TaversableLike private[scala],
which allows overriding it in Stream. The corresponding mima-failures
can be whitelisted, as the changes are only to private[scala].
In 2.12.x we can remove the override of `filter` in Stream, but in
2.11.x this is not binary compatible.
Eventually we'd also like to make filter / filterNot in
TraversableLike final, but that's not source compatible, so it cannot
be done in 2.12.x.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t4332.scala | 2 | ||||
-rw-r--r-- | test/junit/scala/collection/StreamTest.scala | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/test/files/run/t4332.scala b/test/files/run/t4332.scala index 5a67922911..1c7e7d73de 100644 --- a/test/files/run/t4332.scala +++ b/test/files/run/t4332.scala @@ -12,7 +12,7 @@ object Test extends DirectTest { } def isExempt(sym: Symbol) = { - val exempt = Set("view", "repr", "sliceWithKnownDelta", "sliceWithKnownBound", "transform") + val exempt = Set("view", "repr", "sliceWithKnownDelta", "sliceWithKnownBound", "transform", "filterImpl") (exempt contains sym.name.decoded) } diff --git a/test/junit/scala/collection/StreamTest.scala b/test/junit/scala/collection/StreamTest.scala new file mode 100644 index 0000000000..6dc1c79a48 --- /dev/null +++ b/test/junit/scala/collection/StreamTest.scala @@ -0,0 +1,18 @@ +package scala.collection.immutable + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import org.junit.Assert._ + +@RunWith(classOf[JUnit4]) +class StreamTest { + + @Test + def t6727_and_t6440(): Unit = { + assertTrue(Stream.continually(()).filter(_ => true).take(2) == Seq((), ())) + assertTrue(Stream.continually(()).filterNot(_ => false).take(2) == Seq((), ())) + assertTrue(Stream(1,2,3,4,5).filter(_ < 4) == Seq(1,2,3)) + assertTrue(Stream(1,2,3,4,5).filterNot(_ > 4) == Seq(1,2,3,4)) + } +} |