Skip to content
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

Prettifier without Deprecated GenTraversable and GenMap #2134

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions jvm/scalactic/src/main/scala/org/scalactic/Prettifier.scala
Expand Up @@ -141,17 +141,15 @@ private[scalactic] class DefaultPrettifier extends Prettifier {
case a if ArrayHelper.isArrayOps(a) =>
val anArrayOps = ArrayHelper.asArrayOps(a).iterator
"Array(" + anArrayOps.map(prettify(_, processed + anArrayOps)).mkString(", ") + ")"
case aGenMap: scala.collection.GenMap[_, _] =>
ColCompatHelper.className(aGenMap) + "(" +
(aGenMap.toIterator.map { case (key, value) => // toIterator is needed for consistent ordering
prettify(key, processed + aGenMap) + " -> " + prettify(value, processed + aGenMap)
}).mkString(", ") + ")"
case aGenTraversable: GenTraversable[_] =>
val className = aGenTraversable.getClass.getName
case i: Iterable[_] =>
val className = i.getClass.getName
if (className.startsWith("scala.xml.NodeSeq$") || className == "scala.xml.NodeBuffer" || className == "scala.xml.Elem")
aGenTraversable.mkString
i.mkString
else
ColCompatHelper.className(aGenTraversable) + "(" + aGenTraversable.toIterator.map(prettify(_, processed + aGenTraversable)).mkString(", ") + ")" // toIterator is needed for consistent ordering
ColCompatHelper.className(i) + "(" + i.toIterator.map {
case (key, value) if className.contains("Map") => prettify(key, processed + i) + " -> " + prettify(value, processed + i)
case other => prettify(other, processed + i)
}.mkString(", ") + ")" // toIterator is needed for consistent ordering

// SKIP-SCALATESTJS-START
case javaCol: java.util.Collection[_] =>
Expand Down