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

Make StreamingT toString more like Streaming toString #722

Merged
merged 1 commit into from
Dec 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions core/src/main/scala/cats/data/StreamingT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ sealed abstract class StreamingT[F[_], A] extends Product with Serializable { lh
* This method will not force evaluation of any lazy part of a
* stream. As a result, you will see at most one element (the first
* one).
*
* Use .toString(n) to see the first n elements of the stream.
*/
override def toString: String =
"StreamingT(...)"
override def toString: String = this match {
case Cons(a, _) => s"StreamingT($a, ...)"
case Wait(_) => "StreamingT(...)"
case Empty() => "StreamingT()"
}
}

object StreamingT extends StreamingTInstances {
Expand Down
8 changes: 8 additions & 0 deletions tests/src/test/scala/cats/tests/StreamingTTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ class StreamingTTests extends CatsSuite {
StreamingT[Id, Int](x1, x2, tail: _*) should === (fromList)
}
}

test("toString is wrapped in StreamingT()"){
forAll { (xs: StreamingT[Option, Int]) =>
val s = xs.toString
s.take(11) should === ("StreamingT(")
s.last should === (')')
}
}
}

class SpecificStreamingTTests extends CatsSuite {
Expand Down