diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2016-08-12 13:47:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 13:47:32 +0200 |
commit | 14c02acf4c398bcfe293754ea4757b461f4aa653 (patch) | |
tree | bfc9ec9b65bf8c2278ac2c5b048a89c92a4895dc /test | |
parent | 7ff88c0bcba04cf8edbe98d488d14028e6ac399f (diff) | |
parent | c2ca66af4214dcd2e17be038741fe63a47bb2725 (diff) | |
download | scala-14c02acf4c398bcfe293754ea4757b461f4aa653.tar.gz scala-14c02acf4c398bcfe293754ea4757b461f4aa653.tar.bz2 scala-14c02acf4c398bcfe293754ea4757b461f4aa653.zip |
Merge pull request #5259 from szeiger/issue/6881
SI-6881 Detect reference equality when comparing streams
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/immutable/StreamTest.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/junit/scala/collection/immutable/StreamTest.scala b/test/junit/scala/collection/immutable/StreamTest.scala index fad4e502eb..7046525f37 100644 --- a/test/junit/scala/collection/immutable/StreamTest.scala +++ b/test/junit/scala/collection/immutable/StreamTest.scala @@ -107,4 +107,14 @@ class StreamTest { def withFilter_map_properly_lazy_in_tail: Unit = { assertStreamOpLazyInTail(_.withFilter(_ % 2 == 0).map(identity), List(1, 2)) } + + @Test // SI-6881 + def test_reference_equality: Unit = { + // Make sure we're tested with reference equality + val s = Stream.from(0) + assert(s == s, "Referentially identical streams should be equal (==)") + assert(s equals s, "Referentially identical streams should be equal (equals)") + assert((0 #:: 1 #:: s) == (0 #:: 1 #:: s), "Cons of referentially identical streams should be equal (==)") + assert((0 #:: 1 #:: s) equals (0 #:: 1 #:: s), "Cons of referentially identical streams should be equal (equals)") + } } |