Minor. Cleanup test.

This commit is contained in:
Ilya Ryzhenkov
2014-06-06 01:31:04 +04:00
committed by Andrey Breslav
parent 516bae17d7
commit 4e4d0b448c
2 changed files with 9 additions and 11 deletions
@@ -9,7 +9,7 @@ fun fibonacci(): Stream<Int> {
var index = 0;
var a = 0;
var b = 1
return stream<Int> {
return stream {
when (index++) { 0 -> a; 1 -> b; else -> {
val result = a + b; a = b; b = result; result
} }
@@ -81,8 +81,8 @@ public class StreamTest {
test fun plus() {
val stream = listOf("foo", "bar").stream()
val streamChease = stream + "cheese"
assertEquals(listOf("foo", "bar", "cheese"), streamChease.toList())
val streamCheese = stream + "cheese"
assertEquals(listOf("foo", "bar", "cheese"), streamCheese.toList())
// lets use a mutable variable
var mi = listOf("a", "b").stream()
@@ -118,7 +118,7 @@ public class StreamTest {
test fun streamFromFunction() {
var count = 3
val stream = stream<Int> {
val stream = stream {
count--
if (count >= 0) count else null
}
@@ -128,7 +128,7 @@ public class StreamTest {
}
test fun streamFromFunctionWithInitialValue() {
val values = stream<Int>(3) { n -> if (n > 0) n - 1 else null }
val values = stream(3) { n -> if (n > 0) n - 1 else null }
assertEquals(arrayListOf(3, 2, 1, 0), values.toList())
}