Skip to content

Commit

Permalink
Merge pull request playframework#696 from klout/enumeratee-take-impro…
Browse files Browse the repository at this point in the history
…vement

enumeratee.take(0) should not trigger any callbacks
  • Loading branch information
guillaumebort committed Feb 21, 2013
2 parents de0c831 + c462e6b commit 8293620
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ object Enumeratee {
case in => Done(Cont(k), in)
}

def continue[A](k: K[E, A]) = Cont(step(count)(k))
def continue[A](k: K[E, A]) = if (count <= 0) Done(Cont(k), Input.EOF) else Cont(step(count)(k))

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ object EnumerateesSpec extends Specification {

}

"not trigger callback on take 0" in {
var triggered = false
val enumerator = Enumerator.fromCallback {
() =>
triggered = true
Future(Some(1))
}
Await.result(enumerator &> Enumeratee.take(0) |>>> Iteratee.fold(0)(_ + _), Duration.Inf) must equalTo(0)
triggered must beFalse
}

}

"Enumeratee.takeWhile" should {
Expand Down

0 comments on commit 8293620

Please sign in to comment.