standard library: 'sum' function added (KT-3714, KT-3843, KT-3126)

This commit is contained in:
nik
2013-11-24 17:33:05 +04:00
committed by Mikhael Bogdanov
parent 4ecfab6e0b
commit cde36adbdc
14 changed files with 209 additions and 17 deletions
+8
View File
@@ -414,6 +414,14 @@ class CollectionTest {
expect(arrayList(2, 3, 1)) { list }
}
test fun sum() {
expect(0) { ArrayList<Int>().sum() }
expect(14) { arrayListOf(2, 3, 9).sum() }
expect(3.0) { arrayListOf(1.0, 2.0).sum() }
expect(3000000000000) { arrayListOf<Long>(1000000000000, 2000000000000).sum() }
expect(3.0) { arrayListOf<Float>(1.0, 2.0).sum() }
}
class IterableWrapper<T>(collection : Iterable<T>) : Iterable<T> {
private val collection = collection