added support for fold() along with a handy expect() test method (like scalatest)

This commit is contained in:
James Strachan
2012-01-06 09:35:44 +00:00
parent 16b617044c
commit 4627738ca4
3 changed files with 38 additions and 0 deletions
+15
View File
@@ -127,6 +127,21 @@ class CollectionTest() : TestSupport() {
assertEquals(6, count)
}
fun testFold() {
expect(10) {
val numbers = arrayList(1, 2, 3, 4)
// TODO would be nice to be able to write this as this
//numbers.fold(0){it + it2}
numbers.fold(0){(it, it2) -> it + it2}
}
expect(0) {
val numbers = arrayList<Int>()
numbers.fold(0){(it, it2) -> it + it2}
}
}
fun testGroupBy() {
val words = arrayList("a", "ab", "abc", "def", "abcd")
/*