From a7bad9a950e13c3228f0cdfe54cb5aedb5af977f Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Tue, 14 Feb 2017 19:31:29 +0300 Subject: [PATCH] Fix several tests by adding missing stdlib pieces. (#239) --- README.md | 6 +- runtime/src/main/kotlin/kotlin/Arrays.kt | 121 ++++++++++++++++++++--- 2 files changed, 115 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a67b4a8b73c..6924416bb1d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ For an optimized compilation use -opt: ./dist/bin/konanc hello.kt -o hello -opt -For more tests, use: +For some tests, use: ./gradlew backend.native:tests:run + +To run blackbox compiler tests from JVM Kotlin use (takes time): + + ./gradlew run_external \ No newline at end of file diff --git a/runtime/src/main/kotlin/kotlin/Arrays.kt b/runtime/src/main/kotlin/kotlin/Arrays.kt index 0d27b546a89..6af4743b39f 100644 --- a/runtime/src/main/kotlin/kotlin/Arrays.kt +++ b/runtime/src/main/kotlin/kotlin/Arrays.kt @@ -491,17 +491,6 @@ public inline fun Array.lastOrNull(predicate: (T) -> Boolean): T? { return null } -/** - * Returns the range of valid indices for the array. - */ -public val Array.indices: IntRange - get() = IntRange(0, lastIndex) - -/** - * Returns the last valid index for the array. - */ -public val Array.lastIndex: Int - get() = size - 1 /** * Applies the given [transform] function to each element of the original array @@ -589,6 +578,61 @@ public fun Array.sum(): Double { // From _Arrays.kt. +/** + * Returns the range of valid indices for the array. + */ +public val Array.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val ByteArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val ShortArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val IntArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val LongArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val FloatArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val DoubleArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val BooleanArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val CharArray.indices: IntRange + get() = IntRange(0, lastIndex) + + /** * Returns `true` if the array is empty. */ @@ -732,6 +776,61 @@ public inline fun CharArray.isNotEmpty(): Boolean { return !isEmpty() } +/** + * Returns the last valid index for the array. + */ +public val Array.lastIndex: Int + get() = size - 1 + + +/** + * Returns the last valid index for the array. + */ +public val ByteArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val ShortArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val IntArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val LongArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val FloatArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val DoubleArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val BooleanArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val CharArray.lastIndex: Int + get() = size - 1 + /** * Appends all elements to the given [destination] collection. */