Introduce Duration.isPositive method
This commit is contained in:
@@ -75,6 +75,9 @@ public inline class Duration internal constructor(internal val value: Double) :
|
|||||||
/** Returns true, if the duration value is less than zero. */
|
/** Returns true, if the duration value is less than zero. */
|
||||||
public fun isNegative(): Boolean = value < 0
|
public fun isNegative(): Boolean = value < 0
|
||||||
|
|
||||||
|
/** Returns true, if the duration value is greater than zero. */
|
||||||
|
public fun isPositive(): Boolean = value > 0
|
||||||
|
|
||||||
/** Returns true, if the duration value is infinite. */
|
/** Returns true, if the duration value is infinite. */
|
||||||
public fun isInfinite(): Boolean = value.isInfinite()
|
public fun isInfinite(): Boolean = value.isInfinite()
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ class DurationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isNegativeAndAbsoluteValue() {
|
fun signAndAbsoluteValue() {
|
||||||
val negative = -1.seconds
|
val negative = -1.seconds
|
||||||
val positive = 1.seconds
|
val positive = 1.seconds
|
||||||
val zero = Duration.ZERO
|
val zero = Duration.ZERO
|
||||||
@@ -208,6 +208,10 @@ class DurationTest {
|
|||||||
assertFalse(zero.isNegative())
|
assertFalse(zero.isNegative())
|
||||||
assertFalse(positive.isNegative())
|
assertFalse(positive.isNegative())
|
||||||
|
|
||||||
|
assertFalse(negative.isPositive())
|
||||||
|
assertFalse(zero.isPositive())
|
||||||
|
assertTrue(positive.isPositive())
|
||||||
|
|
||||||
assertEquals(positive, negative.absoluteValue)
|
assertEquals(positive, negative.absoluteValue)
|
||||||
assertEquals(positive, positive.absoluteValue)
|
assertEquals(positive, positive.absoluteValue)
|
||||||
assertEquals(zero, zero.absoluteValue)
|
assertEquals(zero, zero.absoluteValue)
|
||||||
|
|||||||
+1
@@ -5317,6 +5317,7 @@ public final class kotlin/time/Duration : java/lang/Comparable {
|
|||||||
public static final fun isFinite-impl (D)Z
|
public static final fun isFinite-impl (D)Z
|
||||||
public static final fun isInfinite-impl (D)Z
|
public static final fun isInfinite-impl (D)Z
|
||||||
public static final fun isNegative-impl (D)Z
|
public static final fun isNegative-impl (D)Z
|
||||||
|
public static final fun isPositive-impl (D)Z
|
||||||
public static final fun minus-LRDsOJo (DD)D
|
public static final fun minus-LRDsOJo (DD)D
|
||||||
public static final fun plus-LRDsOJo (DD)D
|
public static final fun plus-LRDsOJo (DD)D
|
||||||
public static final fun times-impl (DD)D
|
public static final fun times-impl (DD)D
|
||||||
|
|||||||
Reference in New Issue
Block a user