tests changed

val hasNext -> fun hasNext()
This commit is contained in:
Svetlana Isakova
2012-08-14 14:47:04 +04:00
parent f96fe4879a
commit e1281953e7
20 changed files with 42 additions and 48 deletions
@@ -155,12 +155,12 @@ public inline fun <T> Array<T>.foldRight(initial: T, operation: (T, T) -> T): T
*/
public inline fun <T> Array<T>.reduce(operation: (T, T) -> T): T {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: T = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun BooleanArray.foldRight(initial: Boolean, operation: (Boolean,
*/
public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Boolean = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun ByteArray.foldRight(initial: Byte, operation: (Byte, Byte) ->
*/
public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Byte = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun CharArray.foldRight(initial: Char, operation: (Char, Char) ->
*/
public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Char = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun DoubleArray.foldRight(initial: Double, operation: (Double, Dou
*/
public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Double = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun FloatArray.foldRight(initial: Float, operation: (Float, Float)
*/
public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Float = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun IntArray.foldRight(initial: Int, operation: (Int, Int) -> Int)
*/
public inline fun IntArray.reduce(operation: (Int, Int) -> Int): Int {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Int = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun LongArray.foldRight(initial: Long, operation: (Long, Long) ->
*/
public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Long = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}
@@ -155,12 +155,12 @@ public inline fun ShortArray.foldRight(initial: Short, operation: (Short, Short)
*/
public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short {
val iterator = this.iterator().sure()
if (!iterator.hasNext) {
if (!iterator.hasNext()) {
throw UnsupportedOperationException("Empty iterable can't be reduced")
}
var result: Short = iterator.next() //compiler doesn't understand that result will initialized anyway
while (iterator.hasNext) {
while (iterator.hasNext()) {
result = operation(result, iterator.next())
}