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
+10
View File
@@ -101,6 +101,16 @@ class ArraysTest {
assertEquals(false, arr[1])
}
test fun sum() {
expect(0) { array<Int>().sum() }
expect(14) { array(2, 3, 9).sum() }
expect(3.0) { array(1.0, 2.0).sum() }
expect(200) { array<Byte>(100, 100).sum() }
expect(50000) { array<Short>(20000, 30000).sum() }
//TODO: uncomment when toLong() will be supported
//expect(3000000000000) { array<Long>(1000000000000, 2000000000000).sum() }
expect(3.0) { array<Float>(1.0, 2.0).sum() }
}
/*
TODO FIXME ASAP: These currently fail on JS due to missing upto() method on numbers