Skip to content

Commit

Permalink
Merge pull request scala#8089 from NthPortal/topic/MapView-toString-f…
Browse files Browse the repository at this point in the history
…or-real/PR

[bug#11515] Fix View#toString impl
  • Loading branch information
adriaanm authored May 28, 2019
2 parents b616ff0 + 0f64530 commit 24f6f53
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/library/scala/collection/View.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait View[+A] extends Iterable[A] with IterableOps[A, View, View[A]] with Itera

override def empty: scala.collection.View[A] = iterableFactory.empty

override def toString: String = stringPrefix + "(<not computed>)"
override def toString: String = className + "(<not computed>)"

@deprecatedOverriding("Compatibility override", since="2.13.0")
override protected[this] def stringPrefix: String = "View"
Expand Down
14 changes: 14 additions & 0 deletions test/junit/scala/collection/IndexedSeqViewTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scala.collection

import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(classOf[JUnit4])
class IndexedSeqViewTest {
@Test
def _toString(): Unit = {
assertEquals("IndexedSeqView(<not computed>)", IndexedSeq(1, 2, 3).view.toString)
}
}
14 changes: 14 additions & 0 deletions test/junit/scala/collection/MapViewTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scala.collection

import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(classOf[JUnit4])
class MapViewTest {
@Test
def _toString(): Unit = {
assertEquals("MapView(<not computed>)", Map(1 -> 2).view.toString)
}
}
14 changes: 14 additions & 0 deletions test/junit/scala/collection/SeqViewTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package scala.collection

import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(classOf[JUnit4])
class SeqViewTest {
@Test
def _toString(): Unit = {
assertEquals("SeqView(<not computed>)", Seq(1, 2, 3).view.toString)
}
}
8 changes: 7 additions & 1 deletion test/junit/scala/collection/ViewTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,14 @@ class ViewTest {
checkThrows(ll.toList)
}

def t10103: Unit = {
@Test
def t10103(): Unit = {
val ints: IndexedSeq[Int] = Vector(1, 2, 3, 4)
ints.view(1, 3): scala.collection.IndexedSeqView[Int]
}

@Test
def _toString(): Unit = {
assertEquals("View(<not computed>)", View(1, 2, 3).toString)
}
}

0 comments on commit 24f6f53

Please sign in to comment.