Skip to content

Commit

Permalink
improvement: Also print nested arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Jun 19, 2024
1 parent 138580d commit 9d6982c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ object Printing {
out.append(nullableToString(value).replace("\n", ""))
}

inline private def nullableToString[T](value: T) = {
private def nullableToString[T](value: T): String = {
value match
case arr: Array[_] => arr.mkString("Array(", ", ", ")")
case arr: Array[_] => arr.map(nullableToString).mkString("Array(", ", ", ")")
case null => "null"
case _ => value.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,23 @@ class WorksheetSuite extends BaseSuite {
"""
|val x = Array(1, 2, 3)
|val y = Array("a", "b")
|val arrays = Array(Array(1, 2, 3), Array(2, 3, 4))
|""".stripMargin,
"""|<val x = Array(1, 2, 3)> // : Array[Int] = Array...
|x: Array[Int] = Array(1, 2, 3)
|<val y = Array("a", "b")> // : Array[String] = Ar...
|y: Array[String] = Array("a", "b")
|<val arrays = Array(Array(1, 2, 3), Array(2, 3, 4))> // : Array[Array[Int]] ...
|arrays: Array[Array[Int]] = Array(Array(1, 2, 3), Array(2, 3, 4))
|""".stripMargin,
compat = Map(
Compat.Scala3 ->
"""|<val x = Array(1, 2, 3)> // : Array[Int] = Array...
|x: Array[Int] = Array(1, 2, 3)
|<val y = Array("a", "b")> // : Array[String] = Ar...
|y: Array[String] = Array(a, b)
|<val arrays = Array(Array(1, 2, 3), Array(2, 3, 4))> // : Array[Array[Int]] ...
|arrays: Array[Array[Int]] = Array(Array(1, 2, 3), Array(2, 3, 4))
|""".stripMargin
)
)
Expand Down

0 comments on commit 9d6982c

Please sign in to comment.