Generate to[Primitive]Array() methods for generic arrays and collections.

#KT-4180 Fixed
This commit is contained in:
Ilya Gorbunov
2015-04-20 23:15:21 +03:00
parent d18b086113
commit 7fba979372
4 changed files with 231 additions and 0 deletions
@@ -295,6 +295,18 @@ class ArraysTest {
assertEquals(10, intsAsList[1], "Should reflect changes in original array")
}
test fun toPrimitiveArray() {
val genericArray: Array<Int> = array(1, 2, 3)
val primitiveArray: IntArray = genericArray.toIntArray()
expect(3) { primitiveArray.size() }
assertEquals(genericArray.asList(), primitiveArray.asList())
val charList = listOf('a', 'b')
val charArray: CharArray = charList.toCharArray()
assertEquals(charList, charArray.asList())
}
/*
TODO FIXME ASAP: These currently fail on JS due to missing upto() method on numbers