KT-4347 add Array extension indexOf to stdlib

This commit is contained in:
Jon Renner
2013-12-26 13:48:58 +08:00
committed by Andrey Breslav
parent 0a552dbb04
commit 6781231411
12 changed files with 208 additions and 0 deletions
+8
View File
@@ -157,6 +157,14 @@ class ArraysTest {
//expect(3000000000000) { array<Long>(1000000000000, 2000000000000).sum() }
expect(3.0.toFloat()) { array<Float>(1.0.toFloat(), 2.0.toFloat()).sum() }
}
test fun indexOf() {
expect(-1) { array("cat", "dog", "bird").indexOf("mouse") }
expect(0) { array("cat", "dog", "bird").indexOf("cat") }
expect(1) { array("cat", "dog", "bird").indexOf("dog") }
expect(2) { array("cat", "dog", "bird").indexOf("bird") }
expect(0) { array(null, "dog", null).indexOf(null)}
}
/*
TODO FIXME ASAP: These currently fail on JS due to missing upto() method on numbers