Document and test NaN propagation of maxOf/minOf
Also simplify minOf/maxOf implementations #KT-38708
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -100,6 +100,24 @@ class NaNPropagationTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun arrayMinOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> arrayOf(a, b, c).minOf { it } },
|
||||
{ a, b, c -> arrayOf(a, b, c).minOf { it } },
|
||||
"arrayOf().minOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun arrayMaxOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> arrayOf(a, b, c).maxOf { it } },
|
||||
{ a, b, c -> arrayOf(a, b, c).maxOf { it } },
|
||||
"arrayOf().maxOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun primitiveArrayMin() {
|
||||
propagateOf2(
|
||||
@@ -118,6 +136,34 @@ class NaNPropagationTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun primitiveArrayMinOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> doubleArrayOf(a, b, c).minOf { it } },
|
||||
{ a, b, c -> floatArrayOf(a, b, c).minOf { it } },
|
||||
"primitiveArrayOf().minOf()"
|
||||
)
|
||||
propagateOf3(
|
||||
{ a, b, c -> val arr = doubleArrayOf(a, b, c); intArrayOf(0, 1, 2).minOf { arr[it] } },
|
||||
{ a, b, c -> val arr = floatArrayOf(a, b, c); intArrayOf(0, 1, 2).minOf { arr[it] } },
|
||||
"intArrayOf().minOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun primitiveArrayMaxOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> doubleArrayOf(a, b, c).maxOf { it } },
|
||||
{ a, b, c -> floatArrayOf(a, b, c).maxOf { it } },
|
||||
"primitiveArrayOf().maxOf()"
|
||||
)
|
||||
propagateOf3(
|
||||
{ a, b, c -> val arr = doubleArrayOf(a, b, c); intArrayOf(0, 1, 2).maxOf { arr[it] } },
|
||||
{ a, b, c -> val arr = floatArrayOf(a, b, c); intArrayOf(0, 1, 2).maxOf { arr[it] } },
|
||||
"intArrayOf().maxOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listMin() {
|
||||
propagateOf2(
|
||||
@@ -136,6 +182,24 @@ class NaNPropagationTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listMinOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> listOf(a, b, c).minOf { it } },
|
||||
{ a, b, c -> listOf(a, b, c).minOf { it } },
|
||||
"listOf().minOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listMaxOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> listOf(a, b, c).maxOf { it } },
|
||||
{ a, b, c -> listOf(a, b, c).maxOf { it } },
|
||||
"listOf().maxOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sequenceMin() {
|
||||
propagateOf2(
|
||||
@@ -154,6 +218,23 @@ class NaNPropagationTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sequenceMinOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> sequenceOf(a, b, c).minOf { it } },
|
||||
{ a, b, c -> sequenceOf(a, b, c).minOf { it } },
|
||||
"sequenceOf().minOf()"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sequenceMaxOf() {
|
||||
propagateOf3(
|
||||
{ a, b, c -> sequenceOf(a, b, c).maxOf { it } },
|
||||
{ a, b, c -> sequenceOf(a, b, c).maxOf { it } },
|
||||
"sequenceOf().maxOf()"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class NaNTotalOrderTest {
|
||||
|
||||
Reference in New Issue
Block a user