File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
kotlinx-coroutines-core/common Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ public fun <T> Flow<T>.dropWhile(predicate: suspend (T) -> Boolean): Flow<T> = f
5050 */
5151@FlowPreview
5252public fun <T > Flow<T>.take (count : Int ): Flow <T > {
53- require(count >= 0 ) { " Requested element count $count is less than zero." }
54- if (count == 0 ) return emptyFlow()
53+ require(count > 0 ) { " Requested element count $count should be positive" }
5554 return flow {
5655 var consumed = 0
5756 try {
Original file line number Diff line number Diff line change @@ -28,13 +28,15 @@ class TakeTest : TestBase() {
2828 }
2929
3030 @Test
31- fun testNonPositiveValues () = runTest {
31+ fun testNonPositiveValues () {
3232 val flow = flowOf(1 )
3333 assertFailsWith<IllegalArgumentException > {
3434 flow.take(- 1 )
3535 }
3636
37- assertNull(flow.take(0 ).singleOrNull())
37+ assertFailsWith<IllegalArgumentException > {
38+ flow.take(0 )
39+ }
3840 }
3941
4042 @Test
You can’t perform that action at this time.
0 commit comments