diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Days.kt b/core/src/commonMain/generated/io/islandtime/measures/_Days.kt index d08e856c8..00fc0237f 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Days.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Days.kt @@ -37,7 +37,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.days as kotlinDays import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -191,8 +191,7 @@ public value class Days( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.days(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinDays /** * Converts this duration to an ISO-8601 time interval representation. @@ -394,5 +393,4 @@ public operator fun Long.times(days: Days): Days = days * this /** * Converts this duration to Island Time [Days]. */ -@ExperimentalTime public fun KotlinDuration.toIslandDays(): Days = Days(this.toLong(KotlinDurationUnit.DAYS)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Hours.kt b/core/src/commonMain/generated/io/islandtime/measures/_Hours.kt index da2ebfa90..896d9f13e 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Hours.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Hours.kt @@ -36,7 +36,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.hours as kotlinHours import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -178,8 +178,7 @@ public value class Hours( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.hours(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinHours /** * Converts this duration to an ISO-8601 time interval representation. @@ -377,5 +376,4 @@ public operator fun Long.times(hours: Hours): Hours = hours * this /** * Converts this duration to Island Time [Hours]. */ -@ExperimentalTime public fun KotlinDuration.toIslandHours(): Hours = Hours(this.toLong(KotlinDurationUnit.HOURS)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Microseconds.kt b/core/src/commonMain/generated/io/islandtime/measures/_Microseconds.kt index 1525706a9..63e0bcc44 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Microseconds.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Microseconds.kt @@ -37,7 +37,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.microseconds as kotlinMicroseconds import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -187,8 +187,7 @@ public value class Microseconds( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.microseconds(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinMicroseconds /** * Converts this duration to an ISO-8601 time interval representation. @@ -508,6 +507,5 @@ public operator fun Long.times(microseconds: Microseconds): Microseconds = micro /** * Converts this duration to Island Time [Microseconds]. */ -@ExperimentalTime public fun KotlinDuration.toIslandMicroseconds(): Microseconds = Microseconds(this.toLong(KotlinDurationUnit.MICROSECONDS)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Milliseconds.kt b/core/src/commonMain/generated/io/islandtime/measures/_Milliseconds.kt index 17bd9b8d3..7eb79998f 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Milliseconds.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Milliseconds.kt @@ -37,7 +37,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.milliseconds as kotlinMilliseconds import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -185,8 +185,7 @@ public value class Milliseconds( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.milliseconds(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinMilliseconds /** * Converts this duration to an ISO-8601 time interval representation. @@ -472,6 +471,5 @@ public operator fun Long.times(milliseconds: Milliseconds): Milliseconds = milli /** * Converts this duration to Island Time [Milliseconds]. */ -@ExperimentalTime public fun KotlinDuration.toIslandMilliseconds(): Milliseconds = Milliseconds(this.toLong(KotlinDurationUnit.MILLISECONDS)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Minutes.kt b/core/src/commonMain/generated/io/islandtime/measures/_Minutes.kt index 4a7da12d7..2b8d69308 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Minutes.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Minutes.kt @@ -36,7 +36,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.minutes as kotlinMinutes import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -180,8 +180,7 @@ public value class Minutes( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.minutes(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinMinutes /** * Converts this duration to an ISO-8601 time interval representation. @@ -402,6 +401,5 @@ public operator fun Long.times(minutes: Minutes): Minutes = minutes * this /** * Converts this duration to Island Time [Minutes]. */ -@ExperimentalTime public fun KotlinDuration.toIslandMinutes(): Minutes = Minutes(this.toLong(KotlinDurationUnit.MINUTES)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Nanoseconds.kt b/core/src/commonMain/generated/io/islandtime/measures/_Nanoseconds.kt index a796c4a62..9d900c861 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Nanoseconds.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Nanoseconds.kt @@ -37,7 +37,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -189,8 +189,7 @@ public value class Nanoseconds( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.nanoseconds(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinNanoseconds /** * Converts this duration to an ISO-8601 time interval representation. @@ -548,6 +547,5 @@ public operator fun Long.times(nanoseconds: Nanoseconds): Nanoseconds = nanoseco /** * Converts this duration to Island Time [Nanoseconds]. */ -@ExperimentalTime public fun KotlinDuration.toIslandNanoseconds(): Nanoseconds = Nanoseconds(this.toLong(KotlinDurationUnit.NANOSECONDS)) diff --git a/core/src/commonMain/generated/io/islandtime/measures/_Seconds.kt b/core/src/commonMain/generated/io/islandtime/measures/_Seconds.kt index 97d9d5695..bef7feae8 100644 --- a/core/src/commonMain/generated/io/islandtime/measures/_Seconds.kt +++ b/core/src/commonMain/generated/io/islandtime/measures/_Seconds.kt @@ -36,7 +36,7 @@ import kotlin.jvm.JvmInline import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.math.absoluteValue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.seconds as kotlinSeconds import kotlin.time.DurationUnit as KotlinDurationUnit import kotlin.time.Duration as KotlinDuration @@ -182,8 +182,7 @@ public value class Seconds( /** * Converts this duration to a [kotlin.time.Duration]. */ - @ExperimentalTime - public fun toKotlinDuration(): KotlinDuration = KotlinDuration.seconds(value) + public fun toKotlinDuration(): KotlinDuration = value.kotlinSeconds /** * Converts this duration to an ISO-8601 time interval representation. @@ -430,6 +429,5 @@ public operator fun Long.times(seconds: Seconds): Seconds = seconds * this /** * Converts this duration to Island Time [Seconds]. */ -@ExperimentalTime public fun KotlinDuration.toIslandSeconds(): Seconds = Seconds(this.toLong(KotlinDurationUnit.SECONDS)) diff --git a/core/src/commonMain/kotlin/io/islandtime/DateTime.kt b/core/src/commonMain/kotlin/io/islandtime/DateTime.kt index addad21a4..f3887385b 100644 --- a/core/src/commonMain/kotlin/io/islandtime/DateTime.kt +++ b/core/src/commonMain/kotlin/io/islandtime/DateTime.kt @@ -141,7 +141,6 @@ class DateTime( /** * Returns this date-time with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): DateTime { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> this + Seconds(seconds) + Nanoseconds(nanoseconds) } @@ -351,7 +350,6 @@ class DateTime( /** * Returns this date-time with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): DateTime { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> this - Seconds(seconds) - Nanoseconds(nanoseconds) } diff --git a/core/src/commonMain/kotlin/io/islandtime/Instant.kt b/core/src/commonMain/kotlin/io/islandtime/Instant.kt index d4f942680..bc81dde51 100644 --- a/core/src/commonMain/kotlin/io/islandtime/Instant.kt +++ b/core/src/commonMain/kotlin/io/islandtime/Instant.kt @@ -49,7 +49,6 @@ class Instant private constructor( /** * Returns this instant with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): Instant { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> plus(seconds, nanoseconds) } @@ -116,7 +115,6 @@ class Instant private constructor( /** * Returns this instant with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): Instant { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> plus(-seconds, -nanoseconds) } diff --git a/core/src/commonMain/kotlin/io/islandtime/OffsetDateTime.kt b/core/src/commonMain/kotlin/io/islandtime/OffsetDateTime.kt index 92260b049..7dffd804c 100644 --- a/core/src/commonMain/kotlin/io/islandtime/OffsetDateTime.kt +++ b/core/src/commonMain/kotlin/io/islandtime/OffsetDateTime.kt @@ -191,7 +191,6 @@ class OffsetDateTime( /** * Returns this date-time with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): OffsetDateTime = copy(dateTime = dateTime + duration) /** @@ -267,7 +266,6 @@ class OffsetDateTime( /** * Returns this date-time with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): OffsetDateTime = copy(dateTime = dateTime - duration) /** diff --git a/core/src/commonMain/kotlin/io/islandtime/OffsetTime.kt b/core/src/commonMain/kotlin/io/islandtime/OffsetTime.kt index c6e8659a2..5412e45fc 100644 --- a/core/src/commonMain/kotlin/io/islandtime/OffsetTime.kt +++ b/core/src/commonMain/kotlin/io/islandtime/OffsetTime.kt @@ -72,7 +72,6 @@ class OffsetTime( /** * Returns this time with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): OffsetTime = copy(time = time + duration) /** @@ -110,7 +109,6 @@ class OffsetTime( /** * Returns this time with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): OffsetTime = copy(time = time - duration) /** diff --git a/core/src/commonMain/kotlin/io/islandtime/Time.kt b/core/src/commonMain/kotlin/io/islandtime/Time.kt index 8b4c21613..cdb7bc43c 100644 --- a/core/src/commonMain/kotlin/io/islandtime/Time.kt +++ b/core/src/commonMain/kotlin/io/islandtime/Time.kt @@ -81,7 +81,6 @@ class Time( /** * Returns this time with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): Time { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> this + Seconds(seconds) + Nanoseconds(nanoseconds) } @@ -176,7 +175,6 @@ class Time( /** * Returns this time with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): Time { require(duration.isFinite()) { "The duration must be finite" } return duration.toComponents { seconds, nanoseconds -> this - Seconds(seconds) - Nanoseconds(nanoseconds) } diff --git a/core/src/commonMain/kotlin/io/islandtime/ZonedDateTime.kt b/core/src/commonMain/kotlin/io/islandtime/ZonedDateTime.kt index 7da3ae3fa..85eccacc2 100644 --- a/core/src/commonMain/kotlin/io/islandtime/ZonedDateTime.kt +++ b/core/src/commonMain/kotlin/io/islandtime/ZonedDateTime.kt @@ -157,7 +157,6 @@ class ZonedDateTime private constructor( /** * Returns this date-time with [duration] added to it. */ - @kotlin.time.ExperimentalTime operator fun plus(duration: kotlin.time.Duration): ZonedDateTime = resolveInstant(dateTime + duration) /** @@ -236,7 +235,6 @@ class ZonedDateTime private constructor( /** * Returns this date-time with [duration] subtracted from it. */ - @kotlin.time.ExperimentalTime operator fun minus(duration: kotlin.time.Duration): ZonedDateTime = resolveInstant(dateTime - duration) /** diff --git a/core/src/commonMain/kotlin/io/islandtime/measures/Duration.kt b/core/src/commonMain/kotlin/io/islandtime/measures/Duration.kt index b92c214b6..e17a94dfc 100644 --- a/core/src/commonMain/kotlin/io/islandtime/measures/Duration.kt +++ b/core/src/commonMain/kotlin/io/islandtime/measures/Duration.kt @@ -440,7 +440,6 @@ class Duration private constructor( * Converts this duration to a [kotlin.time.Duration]. Since Kotlin's `Duration` type is based on a floating-point * number, precision may be lost. */ - @kotlin.time.ExperimentalTime fun toKotlinDuration(): kotlin.time.Duration { return seconds.toKotlinDuration() + nanosecondAdjustment.toKotlinDuration() } @@ -584,7 +583,7 @@ fun durationOf(nanoseconds: Nanoseconds): Duration { } /** - * Returns the absolute value of [duration]. + * Returns the absolute value of a [duration]. */ fun abs(duration: Duration) = duration.absoluteValue @@ -599,7 +598,6 @@ fun Nanoseconds.asDuration(): Duration = durationOf(this) /** * Converts this duration to an equivalent Island Time [Duration]. */ -@kotlin.time.ExperimentalTime fun kotlin.time.Duration.toIslandDuration(): Duration { return toComponents { seconds, nanoseconds -> durationOf(seconds.seconds, nanoseconds.nanoseconds) } } diff --git a/core/src/commonTest/kotlin/io/islandtime/BuildersTest.kt b/core/src/commonTest/kotlin/io/islandtime/BuildersTest.kt index b0580a709..98ced2af3 100644 --- a/core/src/commonTest/kotlin/io/islandtime/BuildersTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/BuildersTest.kt @@ -22,7 +22,7 @@ class BuildersTest : AbstractIslandTimeTest() { } @Test - fun `Year_atMonth() creates a YearMonth`() { + fun `Year_atMonth creates a YearMonth`() { assertEquals( YearMonth(2018, Month.APRIL), Year(2018).atMonth(4) @@ -40,7 +40,7 @@ class BuildersTest : AbstractIslandTimeTest() { } @Test - fun `YearMonth_atDay() creates a Date`() { + fun `YearMonth_atDay creates a Date`() { assertEquals( Date(2018, Month.MAY, 30), YearMonth(2018, Month.MAY).atDay(30) @@ -144,7 +144,7 @@ class BuildersTest : AbstractIslandTimeTest() { } @Test - fun `Date_startOfDayAt() returns the ZonedDateTime at the start of the day in a time zone`() { + fun `Date_startOfDayAt returns the ZonedDateTime at the start of the day in a time zone`() { assertEquals( ZonedDateTime( DateTime(2019, 5, 20, 0, 0), @@ -157,7 +157,7 @@ class BuildersTest : AbstractIslandTimeTest() { } @Test - fun `Date_endOfDayAt() returns the ZonedDateTime at the end of the day in a time zone`() { + fun `Date_endOfDayAt returns the ZonedDateTime at the end of the day in a time zone`() { assertEquals( ZonedDateTime( DateTime(2019, 5, 20, 23, 59, 59, 999_999_999), diff --git a/core/src/commonTest/kotlin/io/islandtime/ConversionsTest.kt b/core/src/commonTest/kotlin/io/islandtime/ConversionsTest.kt index eabee1ad2..b075f600c 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ConversionsTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ConversionsTest.kt @@ -11,23 +11,23 @@ class ConversionsTest : AbstractIslandTimeTest() { private val denverZone = TimeZone("America/Denver") @Test - fun `YearMonth_toYear() converts to Year`() { + fun `YearMonth_toYear converts to Year`() { assertEquals(Year(2018), YearMonth(2018, Month.JULY).toYear()) } @Test - fun `Date_toYear() converts to Year`() { + fun `Date_toYear converts to Year`() { assertEquals(Year(2018), Date(2018, Month.JULY, 4).toYear()) } @Test - fun `DateTime_toYear() converts to Year`() { + fun `DateTime_toYear converts to Year`() { val dateTime = Date(2019, 3, 3) at Time(7, 0) assertEquals(Year(2019), dateTime.toYear()) } @Test - fun `OffsetDateTime_toYear() converts to Year`() { + fun `OffsetDateTime_toYear converts to Year`() { val offsetDateTime = Date(2019, 3, 3) at Time(7, 0) at (-7).hours.asUtcOffset() @@ -35,24 +35,24 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_toYear() converts to Year`() { + fun `ZonedDateTime_toYear converts to Year`() { val zonedDateTime = DateTime(2019, 3, 3, 7, 0) at denverZone assertEquals(Year(2019), zonedDateTime.toYear()) } @Test - fun `Date_toYearMonth() converts to YearMonth`() { + fun `Date_toYearMonth converts to YearMonth`() { assertEquals(YearMonth(2018, Month.JULY), Date(2018, Month.JULY, 4).toYearMonth()) } @Test - fun `DateTime_toYearMonth() converts to YearMonth`() { + fun `DateTime_toYearMonth converts to YearMonth`() { val dateTime = Date(2019, 3, 3) at Time(7, 0) assertEquals(YearMonth(2019, 3), dateTime.toYearMonth()) } @Test - fun `OffsetDateTime_toYearMonth() converts to YearMonth`() { + fun `OffsetDateTime_toYearMonth converts to YearMonth`() { val offsetDateTime = Date(2019, 3, 3) at Time(7, 0) at (-7).hours.asUtcOffset() @@ -60,13 +60,13 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_toYearMonth() converts to YearMonth`() { + fun `ZonedDateTime_toYearMonth converts to YearMonth`() { val zonedDateTime = DateTime(2019, 3, 3, 7, 0) at denverZone assertEquals(YearMonth(2019, 3), zonedDateTime.toYearMonth()) } @Test - fun `Instant_toDateAt() converts an instant to a Date at a UTC offset`() { + fun `Instant_toDateAt converts an instant to a Date at a UTC offset`() { assertEquals(Date(1970, Month.JANUARY, 1), Instant.UNIX_EPOCH.toDateAt(UtcOffset.ZERO)) assertEquals( @@ -81,7 +81,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `Instant_toDateAt() converts an instant to a Date at a time zone`() { + fun `Instant_toDateAt converts an instant to a Date at a time zone`() { val zone = TimeZone("America/New_York") assertEquals(Date(1970, Month.JANUARY, 1), Instant(5L.hours.inSeconds).toDateAt(zone)) @@ -93,7 +93,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `Instant_toDateTimeAt() converts to DateTime at zone`() { + fun `Instant_toDateTimeAt converts to DateTime at zone`() { val instant = "1980-09-10T14:30Z".toInstant() assertEquals( @@ -103,7 +103,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_toOffsetTime() converts to OffsetTime`() { + fun `OffsetDateTime_toOffsetTime converts to OffsetTime`() { val offsetDateTime = DateTime(2019, 3, 3, 7, 0) at (-7).hours.asUtcOffset() @@ -111,13 +111,13 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_toOffsetTime() converts to OffsetTime`() { + fun `ZonedDateTime_toOffsetTime converts to OffsetTime`() { val zonedDateTime = DateTime(2019, 3, 3, 7, 0) at denverZone assertEquals(OffsetTime(Time(7, 0), UtcOffset((-7).hours)), zonedDateTime.toOffsetTime()) } @Test - fun `ZonedDateTime_toOffsetDateTime() converts to OffsetDateTime`() { + fun `ZonedDateTime_toOffsetDateTime converts to OffsetDateTime`() { assertEquals( "1970-01-01T00:00Z".toOffsetDateTime(), "1970-01-01T00:00Z".toZonedDateTime().toOffsetDateTime() @@ -130,7 +130,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_toZonedDateTime() converts to ZonedDateTime preserving local time`() { + fun `OffsetDateTime_toZonedDateTime converts to ZonedDateTime preserving local time`() { val offsetDateTime = Date(2019, 3, 3) at Time(1, 0) at UtcOffset((-5).hours) @@ -150,7 +150,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_toZonedDateTime() converts to ZonedDateTime preserving instant`() { + fun `OffsetDateTime_toZonedDateTime converts to ZonedDateTime preserving instant`() { val offsetDateTime = Date(2019, 3, 3) at Time(1, 0) at UtcOffset((-5).hours) @@ -170,7 +170,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_asZonedDateTime() converts to a ZonedDateTime with fixed offset zone`() { + fun `OffsetDateTime_asZonedDateTime converts to a ZonedDateTime with fixed offset zone`() { assertEquals( ZonedDateTime.create( DateTime(1970, 1, 1, 0, 0, 0, 0), @@ -191,7 +191,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_toInstant() returns an equivalent Instant`() { + fun `OffsetDateTime_toInstant returns an equivalent Instant`() { assertEquals( "1970-01-01T00:00Z".toInstant(), "1970-01-01T00:00Z".toOffsetDateTime().toInstant() @@ -204,7 +204,7 @@ class ConversionsTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_toInstant() returns an equivalent Instant`() { + fun `ZonedDateTime_toInstant returns an equivalent Instant`() { assertEquals( "1970-01-01T00:00Z".toInstant(), "1970-01-01T00:00Z".toZonedDateTime().toInstant() diff --git a/core/src/commonTest/kotlin/io/islandtime/DatePropertiesTest.kt b/core/src/commonTest/kotlin/io/islandtime/DatePropertiesTest.kt index 9c002a91c..9fd633538 100644 --- a/core/src/commonTest/kotlin/io/islandtime/DatePropertiesTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/DatePropertiesTest.kt @@ -49,11 +49,11 @@ class DatePropertiesTest : AbstractIslandTimeTest() { @Test fun `Date_lengthOfYear returns the length in days of a date's year`() { assertEquals(366.days, Date(2020, FEBRUARY, 29).lengthOfYear) - assertEquals(365.days, Date(2010, Month.MAY, 20).lengthOfYear) + assertEquals(365.days, Date(2010, MAY, 20).lengthOfYear) } @Test - fun `Date_week() with ISO start`() { + fun `Date_week with ISO start`() { val date = Date(2020, MARCH, 6) val expected = Date(2020, MARCH, 2)..Date(2020, MARCH, 8) @@ -62,7 +62,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_week() with Sunday start`() { + fun `Date_week with Sunday start`() { val date = Date(2020, MARCH, 6) val expected = Date(2020, MARCH, 1)..Date(2020, MARCH, 7) @@ -71,7 +71,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_week() with ISO start`() { + fun `DateTime_week with ISO start`() { val dateTime = DateTime(2020, MARCH, 6, 13, 30) val start = Date(2020, MARCH, 2) at MIDNIGHT val end = Date(2020, MARCH, 8) at Time.MAX @@ -81,7 +81,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_week() with Sunday start`() { + fun `DateTime_week with Sunday start`() { val dateTime = DateTime(2020, MARCH, 6, 13, 30) val start = Date(2020, MARCH, 1) at MIDNIGHT val end = Date(2020, MARCH, 7) at Time.MAX @@ -91,7 +91,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_week() with ISO start`() { + fun `OffsetDateTime_week with ISO start`() { // Note: DST transition occurs at 2AM on March 8 val offsetDateTime = DateTime(2020, MARCH, 6, 13, 30) at UtcOffset((-5).hours) val start = Date(2020, MARCH, 2) at MIDNIGHT at UtcOffset((-5).hours) @@ -102,7 +102,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_week() with Sunday start`() { + fun `OffsetDateTime_week with Sunday start`() { val offsetDateTime = DateTime(2020, MARCH, 6, 13, 30) at UtcOffset((-5).hours) val start = Date(2020, MARCH, 1) at MIDNIGHT at UtcOffset((-5).hours) val end = Date(2020, MARCH, 7) at Time.MAX at UtcOffset((-5).hours) @@ -112,7 +112,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_week() with ISO start`() { + fun `ZonedDateTime_week with ISO start`() { // Note: DST transition occurs at 2AM on March 8 val zonedDateTime = DateTime(2020, MARCH, 6, 13, 30) at nyZone val start = Date(2020, MARCH, 2) at MIDNIGHT at nyZone @@ -123,7 +123,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_week() with Sunday start`() { + fun `ZonedDateTime_week with Sunday start`() { val zonedDateTime = DateTime(2020, MARCH, 6, 13, 30) at nyZone val start = Date(2020, MARCH, 1) at MIDNIGHT at nyZone val end = Date(2020, MARCH, 7) at Time.MAX at nyZone @@ -146,7 +146,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_weekOfMonth() with Sunday start`() { + fun `Date_weekOfMonth with Sunday start`() { listOf( Date(2008, 12, 27) to 4, Date(2008, 12, 28) to 5, @@ -162,7 +162,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_weekOfMonth() with custom week definition`() { + fun `Date_weekOfMonth with custom week definition`() { listOf( Date(2008, 12, 28) to 4, Date(2008, 12, 29) to 5, @@ -193,7 +193,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_weekOfYear() with Sunday start`() { + fun `Date_weekOfYear with Sunday start`() { listOf( Date(2008, 12, 27) to 52, Date(2008, 12, 28) to 53, @@ -208,7 +208,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_weekOfYear() with custom week definition`() { + fun `Date_weekOfYear with custom week definition`() { listOf( Date(2008, 12, 28) to 52, Date(2008, 12, 29) to 53, @@ -274,7 +274,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_next() returns the next date with a particular day of week`() { + fun `Date_next returns the next date with a particular day of week`() { assertEquals( Date(2019, OCTOBER, 11), Date(2019, OCTOBER, 10).next(FRIDAY) @@ -297,7 +297,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_nextOrSame() returns the next date with a particular day of week or this one if it's the same`() { + fun `Date_nextOrSame returns the next date with a particular day of week or this one if it's the same`() { assertEquals( Date(2019, OCTOBER, 11), Date(2019, OCTOBER, 10).nextOrSame(FRIDAY) @@ -320,7 +320,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_previous() returns the last date with a particular day of week`() { + fun `Date_previous returns the last date with a particular day of week`() { assertEquals( Date(2019, OCTOBER, 9), Date(2019, OCTOBER, 10).previous(WEDNESDAY) @@ -343,7 +343,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `Date_previousOrSame() returns the last date with a particular day of week or this one if it's the same`() { + fun `Date_previousOrSame returns the last date with a particular day of week or this one if it's the same`() { assertEquals( Date(2019, OCTOBER, 9), Date(2019, OCTOBER, 10).previousOrSame(WEDNESDAY) @@ -366,7 +366,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_next() returns the next date-time with a particular day of week`() { + fun `DateTime_next returns the next date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 17, 1, 1, 1, 1), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -375,7 +375,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_nextOrSame() returns the next date-time with a particular day of week or the same`() { + fun `DateTime_nextOrSame returns the next date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -384,7 +384,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_previous() returns the last date-time with a particular day of week`() { + fun `DateTime_previous returns the last date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 3, 1, 1, 1, 1), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -393,7 +393,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_previousOrSame() returns the last date-time with a particular day of week or the same`() { + fun `DateTime_previousOrSame returns the last date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -402,7 +402,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_next() returns the next date-time with a particular day of week`() { + fun `OffsetDateTime_next returns the next date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 17, 1, 1, 1, 1) .at(1.hours.asUtcOffset()), @@ -413,7 +413,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_nextOrSame() returns the next date-time with a particular day of week or the same`() { + fun `OffsetDateTime_nextOrSame returns the next date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) .at(1.hours.asUtcOffset()), @@ -424,7 +424,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_previous() returns the last date-time with a particular day of week`() { + fun `OffsetDateTime_previous returns the last date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 3, 1, 1, 1, 1) .at(1.hours.asUtcOffset()), @@ -435,7 +435,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_previousOrSame() returns the last date-time with a particular day of week or the same`() { + fun `OffsetDateTime_previousOrSame returns the last date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) .at(1.hours.asUtcOffset()), @@ -446,7 +446,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_next() returns the next date-time with a particular day of week`() { + fun `ZonedDateTime_next returns the next date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 17, 1, 1, 1, 1).at(nyZone), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -456,7 +456,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_nextOrSame() returns the next date-time with a particular day of week or the same`() { + fun `ZonedDateTime_nextOrSame returns the next date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1).at(nyZone), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -466,7 +466,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_previous() returns the last date-time with a particular day of week`() { + fun `ZonedDateTime_previous returns the last date-time with a particular day of week`() { assertEquals( DateTime(2019, OCTOBER, 3, 1, 1, 1, 1).at(nyZone), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) @@ -476,7 +476,7 @@ class DatePropertiesTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_previousOrSame() returns the last date-time with a particular day of week or the same`() { + fun `ZonedDateTime_previousOrSame returns the last date-time with a particular day of week or the same`() { assertEquals( DateTime(2019, OCTOBER, 10, 1, 1, 1, 1).at(nyZone), DateTime(2019, OCTOBER, 10, 1, 1, 1, 1) diff --git a/core/src/commonTest/kotlin/io/islandtime/DateTest.kt b/core/src/commonTest/kotlin/io/islandtime/DateTest.kt index f207f42d9..95aee0687 100644 --- a/core/src/commonTest/kotlin/io/islandtime/DateTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/DateTest.kt @@ -43,7 +43,7 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `copy() creates a new Date, replacing any combination of values`() { + fun `copy creates a new Date replacing any combination of values`() { assertEquals( Date(2017, Month.NOVEMBER, 19), Date(2018, Month.NOVEMBER, 19).copy(year = 2017) @@ -143,7 +143,7 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `adding a period first adds years, then months, then days`() { + fun `adding a period adds years then months then days`() { assertEquals( Date(2017, Month.MARCH, 29), Date(2016, Month.FEBRUARY, 29) + periodOf(1.years, 1.months, 1.days) @@ -164,7 +164,7 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `subtracting a period first subtracts years, then months, then days`() { + fun `subtracting a period subtracts years then months then days`() { assertEquals( Date(2017, Month.MARCH, 29), Date(2016, Month.FEBRUARY, 29) - periodOf((-1).years, (-1).months, (-1).days) @@ -690,18 +690,18 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 extended calendar date`() { + fun `toString returns an ISO-8601 extended calendar date`() { assertEquals("2019-08-01", Date(2019, Month.AUGUST, 1).toString()) assertEquals("0001-10-10", Date(1, Month.OCTOBER, 10).toString()) } @Test - fun `String_toDate() throws an exception when given an empty string`() { + fun `String_toDate throws an exception when given an empty string`() { assertFailsWith { "".toDate() } } @Test - fun `String_toDate() throws an exception when the format is not an ISO-8601 extended date`() { + fun `String_toDate throws an exception when the format is not an ISO-8601 extended date`() { listOf( "1", "--", @@ -720,27 +720,27 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `String_toDate() throws an exception when unexpected characters exist before a valid string`() { + fun `String_toDate throws an exception when unexpected characters exist before a valid string`() { assertFailsWith { " 2010-02-20".toDate() } assertFailsWith { "T2010-10-20".toDate() } } @Test - fun `String_toDate() throws an exception when unexpected characters exist after a valid string`() { + fun `String_toDate throws an exception when unexpected characters exist after a valid string`() { assertFailsWith { "2010-2-20 ".toDate() } assertFailsWith { "2010-10-200".toDate() } assertFailsWith { "2010-10-20T".toDate() } } @Test - fun `String_toDate() throws an exception when the parser cannot supply the required fields`() { + fun `String_toDate throws an exception when the parser cannot supply the required fields`() { assertFailsWith { "05:06".toDate(DateTimeParsers.Iso.TIME) } assertFailsWith { "2010".toDate(DateTimeParsers.Iso.YEAR) } assertFailsWith { "2010-05".toDate(DateTimeParsers.Iso.YEAR_MONTH) } } @Test - fun `String_toDate() throws an exception when fields overflow`() { + fun `String_toDate throws an exception when fields overflow`() { val customParser = dateTimeParser { year() +' ' @@ -753,7 +753,7 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `String_toDate() parses valid ISO-8601 extended date strings by default`() { + fun `String_toDate parses valid ISO-8601 extended date strings by default`() { listOf( "2000-02-29" to Date(2000, Month.FEBRUARY, 29), "+999999999-12-31" to Date(999_999_999, Month.DECEMBER, 31), @@ -764,7 +764,7 @@ class DateTest : AbstractIslandTimeTest() { } @Test - fun `String_toDate() parses valid strings with explicit parser`() { + fun `String_toDate parses valid strings with explicit parser`() { listOf( "2000-02-29", "20000229", diff --git a/core/src/commonTest/kotlin/io/islandtime/DateTimeTest.kt b/core/src/commonTest/kotlin/io/islandtime/DateTimeTest.kt index 0ecd93b0e..455b79463 100644 --- a/core/src/commonTest/kotlin/io/islandtime/DateTimeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/DateTimeTest.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalTime::class) - package io.islandtime import io.islandtime.measures.* @@ -11,7 +9,8 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.hours as kotlinHours +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds class DateTimeTest : AbstractIslandTimeTest() { @Test @@ -101,7 +100,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() returns a new DateTime replacing the desired values`() { + fun `copy returns a new DateTime replacing the desired values`() { assertEquals( DateTime(2018, Month.MAY, 8, 12, 0), DateTime(2018, Month.MAY, 4, 18, 0).copy(hour = 12, dayOfMonth = 8) @@ -134,7 +133,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `secondsSinceUnixEpochAt() returns the number of seconds since the unix epoch`() { + fun `secondsSinceUnixEpochAt returns the number of seconds since the unix epoch`() { assertEquals( 1L.seconds, (Date(1970, Month.JANUARY, 1) at Time(1, 0, 1)) @@ -161,7 +160,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `millisecondsSinceUnixEpochAt() returns the number of milliseconds since the unix epoch`() { + fun `millisecondsSinceUnixEpochAt returns the number of milliseconds since the unix epoch`() { assertEquals( 1L.milliseconds, (Date(1970, Month.JANUARY, 1) at Time(1, 0, 0, 1_999_999)) @@ -194,7 +193,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `millisecondOfUnixEpochAt() returns the millisecond of the unix epoch`() { + fun `millisecondOfUnixEpochAt returns the millisecond of the unix epoch`() { assertEquals( 1L, (Date(1970, Month.JANUARY, 1) at Time(1, 0, 0, 1_999_999)) @@ -235,7 +234,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `adding a period first adds years, then months, then days`() { + fun `adding a period adds years then months then days`() { assertEquals( DateTime(2017, Month.MARCH, 29, 9, 0), DateTime(2016, Month.FEBRUARY, 29, 9, 0) + @@ -258,7 +257,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `subtracting a period first subtracts years, then months, then days`() { + fun `subtracting a period subtracts years then months then days`() { assertEquals( DateTime(2017, Month.MARCH, 29, 9, 0), DateTime(2016, Month.FEBRUARY, 29, 9, 0) - @@ -317,8 +316,7 @@ class DateTimeTest : AbstractIslandTimeTest() { fun `add a kotlin duration`() { assertEquals( Date(2010, Month.JULY, 4) at Time(18, 0), - (Date(2010, Month.JULY, 3) at Time.MAX) + - (kotlin.time.Duration.hours(18) + kotlin.time.Duration.nanoseconds(1)) + (Date(2010, Month.JULY, 3) at Time.MAX) + (18.kotlinHours + 1.kotlinNanoseconds) ) } @@ -339,7 +337,7 @@ class DateTimeTest : AbstractIslandTimeTest() { assertEquals( Date(2010, Month.JULY, 4) at Time(18, 0), (Date(2010, Month.JULY, 5) at Time(1, 0, 0, 1)) - - (kotlin.time.Duration.hours(7) + kotlin.time.Duration.nanoseconds(1)) + (7.kotlinHours + 1.kotlinNanoseconds) ) } @@ -918,7 +916,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 extended calendar date time`() { + fun `toString returns an ISO-8601 extended calendar date time`() { assertEquals( "2019-08-01T00:01", DateTime(2019, Month.AUGUST, 1, 0, 1).toString() @@ -930,25 +928,25 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateTime() throws an exception when the format is mixed basic and extended`() { + fun `String_toDateTime throws an exception when the format is mixed basic and extended`() { assertFailsWith { "20000101 00:23".toDateTime() } assertFailsWith { "2002-02-01T0023".toDateTime() } } @Test - fun `String_toDateTime() throws an exception when given an empty string`() { + fun `String_toDateTime throws an exception when given an empty string`() { assertFailsWith { "".toDateTime() } } @Test - fun `String_toDateTime() throws an exception when the parser can't supply required fields`() { + fun `String_toDateTime throws an exception when the parser can't supply required fields`() { assertFailsWith { "08:00".toDateTime(DateTimeParsers.Iso.UTC_OFFSET) } assertFailsWith { "08:00".toDateTime(DateTimeParsers.Iso.TIME) } assertFailsWith { "2009-10-08".toDateTime(DateTimeParsers.Iso.DATE) } } @Test - fun `String_toDateTime() parses valid ISO-8601 extended calendar date strings by default`() { + fun `String_toDateTime parses valid ISO-8601 extended calendar date strings by default`() { assertEquals( DateTime(2019, Month.MARCH, 23, 2, 30), "2019-03-23T02:30".toDateTime() @@ -961,7 +959,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateTime() parses valid ISO-8601 basic calendar date strings`() { + fun `String_toDateTime parses valid ISO-8601 basic calendar date strings`() { assertEquals( DateTime(2019, Month.MARCH, 23, 2, 30), "20190323T0230".toDateTime(DateTimeParsers.Iso.Basic.DATE_TIME) @@ -969,7 +967,7 @@ class DateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateTime() parses valid ISO-8601 ordinal date strings with custom parser`() { + fun `String_toDateTime parses valid ISO-8601 ordinal date strings with custom parser`() { val parser = dateTimeParser { anyOf({ childParser(DateTimeParsers.Iso.Basic.DATE) diff --git a/core/src/commonTest/kotlin/io/islandtime/DayOfWeekTest.kt b/core/src/commonTest/kotlin/io/islandtime/DayOfWeekTest.kt index e0f0b75a7..8e28a80b1 100644 --- a/core/src/commonTest/kotlin/io/islandtime/DayOfWeekTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/DayOfWeekTest.kt @@ -16,21 +16,21 @@ class DayOfWeekTest : AbstractIslandTimeTest() { private val ar_EG = "ar-EG".toLocale() @Test - fun `Int_toDayOfWeek() throws an exception when the number is out of range`() { + fun `Int_toDayOfWeek throws an exception when the number is out of range`() { assertFailsWith { 0.toDayOfWeek() } assertFailsWith { 8.toDayOfWeek() } assertFailsWith { (-1).toDayOfWeek() } } @Test - fun `Int_toDayOfWeek() returns the correct day`() { + fun `Int_toDayOfWeek returns the correct day`() { assertEquals(DayOfWeek.MONDAY, 1.toDayOfWeek()) assertEquals(DayOfWeek.WEDNESDAY, 3.toDayOfWeek()) assertEquals(DayOfWeek.SUNDAY, 7.toDayOfWeek()) } @Test - fun `Int_toDayOfWeek() with settings`() { + fun `Int_toDayOfWeek with settings`() { assertEquals(DayOfWeek.SUNDAY, 1.toDayOfWeek(WeekSettings.SUNDAY_START)) assertEquals(DayOfWeek.MONDAY, 2.toDayOfWeek(WeekSettings.SUNDAY_START)) assertEquals(DayOfWeek.SATURDAY, 7.toDayOfWeek(WeekSettings.SUNDAY_START)) @@ -47,7 +47,7 @@ class DayOfWeekTest : AbstractIslandTimeTest() { } @Test - fun `number() matches week settings`() { + fun `number matches week settings`() { assertEquals(1, DayOfWeek.SUNDAY.number(WeekSettings.SUNDAY_START)) assertEquals(7, DayOfWeek.SATURDAY.number(WeekSettings.SUNDAY_START)) @@ -60,7 +60,7 @@ class DayOfWeekTest : AbstractIslandTimeTest() { } @Test - fun `number() matches locale`() { + fun `number matches locale`() { assertEquals(1, DayOfWeek.SUNDAY.number(en_US)) assertEquals(7, DayOfWeek.SATURDAY.number(en_US)) @@ -72,7 +72,7 @@ class DayOfWeekTest : AbstractIslandTimeTest() { } @Test - fun `localizedName() and displayName() get localized text from the provider`() { + fun `localizedName and displayName get localized text from the provider`() { assertEquals("Wednesday", DayOfWeek.WEDNESDAY.localizedName(TextStyle.FULL_STANDALONE, en_US)) assertEquals("Wed", DayOfWeek.WEDNESDAY.displayName(TextStyle.SHORT_STANDALONE, en_US)) } diff --git a/core/src/commonTest/kotlin/io/islandtime/InstantTest.kt b/core/src/commonTest/kotlin/io/islandtime/InstantTest.kt index 3fe6fae91..001657e9c 100644 --- a/core/src/commonTest/kotlin/io/islandtime/InstantTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/InstantTest.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalTime::class) - package io.islandtime import io.islandtime.measures.* @@ -9,7 +7,8 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.hours as kotlinHours +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds class InstantTest : AbstractIslandTimeTest() { @Test @@ -219,9 +218,7 @@ class InstantTest : AbstractIslandTimeTest() { fun `add a kotlin duration`() { assertEquals( Instant(1.hours.inSeconds, 2.nanoseconds), - Instant(0.seconds, 1.nanoseconds) + - (kotlin.time.Duration.hours(1) + - kotlin.time.Duration.nanoseconds(1)) + Instant(0.seconds, 1.nanoseconds) + (1.kotlinHours + 1.kotlinNanoseconds) ) } @@ -240,14 +237,12 @@ class InstantTest : AbstractIslandTimeTest() { fun `subtract a kotlin duration`() { assertEquals( Instant((-1).hours.inSeconds, 0.nanoseconds), - Instant(0.seconds, 1.nanoseconds) - - (kotlin.time.Duration.hours(1) + - kotlin.time.Duration.nanoseconds(1)) + Instant(0.seconds, 1.nanoseconds) - (1.kotlinHours + 1.kotlinNanoseconds) ) } @Test - fun `toString() returns an ISO-8601 extended date-time with UTC offset`() { + fun `toString returns an ISO-8601 extended date-time with UTC offset`() { assertEquals( "1970-01-01T00:00Z", Instant.UNIX_EPOCH.toString() @@ -280,13 +275,13 @@ class InstantTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstant() throws an exception when parsing an empty string`() { + fun `String_toInstant throws an exception when parsing an empty string`() { assertFailsWith { "".toInstant() } assertFailsWith { "".toInstant(DateTimeParsers.Iso.INSTANT) } } @Test - fun `String_toInstant() throws an exception when the format is unexpected`() { + fun `String_toInstant throws an exception when the format is unexpected`() { listOf( "20191205 0304", "2019-12-05T03:04", @@ -297,7 +292,7 @@ class InstantTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstant() throws an exception when fields are out of range`() { + fun `String_toInstant throws an exception when fields are out of range`() { listOf( "2000-01-01T24:00Z", "2000-01-01T08:60Z", @@ -311,7 +306,7 @@ class InstantTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstant() parses ISO-8601 calendar date time strings in extended format by default`() { + fun `String_toInstant parses ISO-8601 calendar date time strings in extended format by default`() { assertEquals( Instant.fromMillisecondOfUnixEpoch(0L), "1970-01-01T00:00Z".toInstant() @@ -334,7 +329,7 @@ class InstantTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstant() parses ISO-8601 calendar date time strings in basic format with explicit parser`() { + fun `String_toInstant parses ISO-8601 calendar date time strings in basic format with explicit parser`() { assertEquals( Instant.fromMillisecondOfUnixEpoch(0L), "19700101 0000Z".toInstant(DateTimeParsers.Iso.INSTANT) @@ -347,7 +342,7 @@ class InstantTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstant() throws an exception when required fields are missing`() { + fun `String_toInstant throws an exception when required fields are missing`() { val parser1 = dateTimeParser { monthNumber(2) +'-' diff --git a/core/src/commonTest/kotlin/io/islandtime/MonthTest.kt b/core/src/commonTest/kotlin/io/islandtime/MonthTest.kt index 802de55d7..ce919dae6 100644 --- a/core/src/commonTest/kotlin/io/islandtime/MonthTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/MonthTest.kt @@ -11,13 +11,13 @@ import kotlin.test.assertFailsWith class MonthTest : AbstractIslandTimeTest() { @Test - fun `Int_toMonth() throws an exception when the value isn't a valid ISO month number`() { + fun `Int_toMonth throws an exception when the value isn't a valid ISO month number`() { assertFailsWith { 0.toMonth() } assertFailsWith { 13.toMonth() } } @Test - fun `Int_toMonth() gets a Month from an ISO month number when it's in range`() { + fun `Int_toMonth gets a Month from an ISO month number when it's in range`() { assertEquals(Month.JANUARY, 1.toMonth()) assertEquals(Month.APRIL, 4.toMonth()) assertEquals(Month.DECEMBER, 12.toMonth()) @@ -44,7 +44,7 @@ class MonthTest : AbstractIslandTimeTest() { } @Test - fun `lengthIn() works correctly`() { + fun `lengthIn works correctly`() { assertEquals(31.days, Month.JANUARY.lengthIn(2019)) assertEquals(28.days, Month.FEBRUARY.lengthIn(2019)) assertEquals(29.days, Month.FEBRUARY.lengthIn(2020)) @@ -61,7 +61,7 @@ class MonthTest : AbstractIslandTimeTest() { } @Test - fun `firstDayOfYearIn() returns the first day of yera for the month`() { + fun `firstDayOfYearIn returns the first day of yera for the month`() { assertEquals(1, Month.JANUARY.firstDayOfYearIn(1950)) assertEquals(1, Month.JANUARY.firstDayOfYearIn(2000)) assertEquals(244, Month.SEPTEMBER.firstDayOfYearIn(2001)) @@ -69,7 +69,7 @@ class MonthTest : AbstractIslandTimeTest() { } @Test - fun `lastDayOfYearIn() returns the last day of year for the month`() { + fun `lastDayOfYearIn returns the last day of year for the month`() { assertEquals(59, Month.FEBRUARY.lastDayOfYearIn(2019)) assertEquals(60, Month.FEBRUARY.lastDayOfYearIn(2020)) assertEquals(365, Month.DECEMBER.lastDayOfYearIn(2019)) @@ -77,21 +77,21 @@ class MonthTest : AbstractIslandTimeTest() { } @Test - fun `localizedName() and displayName() get localized text from the provider`() { + fun `localizedName and displayName get localized text from the provider`() { @Suppress("LocalVariableName") val en_US = "en-US".toLocale() assertEquals("April", Month.APRIL.localizedName(TextStyle.FULL_STANDALONE, en_US)) assertEquals("Jun", Month.JUNE.displayName(TextStyle.SHORT_STANDALONE, en_US)) } @Test - fun `dayRangeIn() returns an appropriate range in leap years`() { + fun `dayRangeIn returns an appropriate range in leap years`() { val range = Month.FEBRUARY.dayRangeIn(2020) assertEquals(1, range.first) assertEquals(29, range.last) } @Test - fun `dayRangeIn() returns an appropriate range in common years`() { + fun `dayRangeIn returns an appropriate range in common years`() { val range = Month.FEBRUARY.dayRangeIn(2019) assertEquals(1, range.first) assertEquals(28, range.last) diff --git a/core/src/commonTest/kotlin/io/islandtime/OffsetDateTimeTest.kt b/core/src/commonTest/kotlin/io/islandtime/OffsetDateTimeTest.kt index 8f41955ed..ff9046e19 100644 --- a/core/src/commonTest/kotlin/io/islandtime/OffsetDateTimeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/OffsetDateTimeTest.kt @@ -108,7 +108,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `equality is based on date, time, and offset`() { + fun `equality is based on date time and offset`() { assertFalse { Date(1969, 365) at Time(23, 0) at UtcOffset((-1).hours) == Date(1970, 1) at Time(0, 0) at UtcOffset.ZERO @@ -120,7 +120,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `compareTo() compares based on instant only`() { + fun `compareTo compares based on instant only`() { assertTrue { (Date(1969, 365) at Time(23, 0) at UtcOffset((-1).hours)) .compareTo(Date(1970, 1) at Time(0, 0) at UtcOffset.ZERO) == 0 @@ -133,7 +133,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `DefaultSortOrder compares based on instant, then date and time when there are differing offsets`() { + fun `DefaultSortOrder compares based on instant then date and time when there are differing offsets`() { assertTrue { OffsetDateTime.DefaultSortOrder.compare( Date(1969, 365) at Time(23, 0) at UtcOffset((-1).hours), @@ -165,7 +165,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() can be used to replace individual date or time components`() { + fun `copy can be used to replace individual date or time components`() { assertEquals( (Date(2019, Month.FEBRUARY, 1) at Time.NOON at UtcOffset.ZERO), (Date(2019, Month.JANUARY, 1) at Time.NOON at UtcOffset.ZERO).copy(dayOfYear = 32) @@ -192,7 +192,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `adjustedTo() changes the offset while preserving the instant represented by it`() { + fun `adjustedTo changes the offset while preserving the instant represented by it`() { assertEquals( DateTime(2000, Month.APRIL, 4, 7, 0) at UtcOffset.MIN, DateTime(2000, Month.APRIL, 5, 1, 0).at(UtcOffset.ZERO).adjustedTo(UtcOffset.MIN) @@ -204,7 +204,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns ISO-8601 extended representation of the date, time, and offset`() { + fun `toString returns ISO-8601 extended representation of the date + time + offset`() { assertEquals( "2018-05-05T12:00Z", OffsetDateTime( @@ -231,18 +231,18 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetDateTime() throws an exception when the string is empty`() { + fun `String_toOffsetDateTime throws an exception when the string is empty`() { assertFailsWith { "".toOffsetDateTime() } } @Test - fun `String_toOffsetDateTime() throws an exception when format is unexpected`() { + fun `String_toOffsetDateTime throws an exception when format is unexpected`() { assertFailsWith { "20191205 12:00+00".toOffsetDateTime() } assertFailsWith { "2019-12-05T1200+00".toOffsetDateTime() } } @Test - fun `String_toOffsetDateTime() throws an exception when fields are out of range`() { + fun `String_toOffsetDateTime throws an exception when fields are out of range`() { assertFailsWith { "2000-01-01T24:00+01:00".toOffsetDateTime() } assertFailsWith { "2000-01-01T08:60-01:00".toOffsetDateTime() } assertFailsWith { "2000-13-01T08:59-01:00".toOffsetDateTime() } @@ -250,7 +250,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetDateTime() parses valid ISO-8601 calendar date time strings in extended format by default`() { + fun `String_toOffsetDateTime parses valid ISO-8601 calendar date time strings in extended format by default`() { assertEquals( OffsetDateTime( DateTime(Date(2019, Month.MAY, 5), Time.NOON), @@ -269,7 +269,7 @@ class OffsetDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetDateTime() parses valid ISO-8601 strings with explicit parser`() { + fun `String_toOffsetDateTime parses valid ISO-8601 strings with explicit parser`() { assertEquals( OffsetDateTime( DateTime(Date(2019, Month.MAY, 5), Time.NOON), diff --git a/core/src/commonTest/kotlin/io/islandtime/OffsetTimeTest.kt b/core/src/commonTest/kotlin/io/islandtime/OffsetTimeTest.kt index 429c6dac4..0585c2eb1 100644 --- a/core/src/commonTest/kotlin/io/islandtime/OffsetTimeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/OffsetTimeTest.kt @@ -13,7 +13,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { private val time1234 = Time(1, 2, 3, 4) at UtcOffset.MAX @Test - fun `compareTo() compares based on instant only`() { + fun `compareTo compares based on instant only`() { assertTrue { Time.MIN at UtcOffset.ZERO < Time(0, 0, 0, 1) at UtcOffset.ZERO } assertTrue { Time.MAX at UtcOffset.MIN > Time(23, 59, 59) at UtcOffset.MIN } assertTrue { @@ -68,7 +68,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `DefaultSortOrder compares based on instant, then time when there are differing offsets`() { + fun `DefaultSortOrder compares based on instant then time when there are differing offsets`() { assertTrue { OffsetTime.DefaultSortOrder.compare( Time(1, 0, 0, 1) at UtcOffset((-1).hours), @@ -106,7 +106,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() can be used to replace individual time components`() { + fun `copy can be used to replace individual time components`() { assertEquals( (Time(5, 2, 3, 4) at UtcOffset.MAX), time1234.copy(hour = 5) @@ -126,7 +126,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() can be used to replace the whole time`() { + fun `copy can be used to replace the whole time`() { val newTime = Time(2, 3, 4, 5) assertEquals( @@ -136,7 +136,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() can be used to change the offset without adjusting the local time`() { + fun `copy can be used to change the offset without adjusting the local time`() { assertEquals( Time(5, 0) at UtcOffset(1.hours), (Time(5, 0) at UtcOffset.ZERO).copy(offset = UtcOffset(1.hours)) @@ -144,7 +144,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 extended time with offset`() { + fun `toString returns an ISO-8601 extended time with offset`() { assertEquals( "05:00Z", Time(5, 0).at(UtcOffset.ZERO).toString() @@ -166,24 +166,24 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetTime() throws an exception when the string is empty`() { + fun `String_toOffsetTime throws an exception when the string is empty`() { assertFailsWith { "".toOffsetTime() } } @Test - fun `String_toOffsetTime() throws an exception when format is unexpected`() { + fun `String_toOffsetTime throws an exception when format is unexpected`() { assertFailsWith { "0800+01".toOffsetTime() } assertFailsWith { "8-01".toOffsetTime() } } @Test - fun `String_toOffsetTime() throws an exception when time is out of range`() { + fun `String_toOffsetTime throws an exception when time is out of range`() { assertFailsWith { "24:00+01:00".toOffsetTime() } assertFailsWith { "08:60-01:00".toOffsetTime() } } @Test - fun `String_toOffsetTime() parses valid ISO-8601 extended time and offset strings by default`() { + fun `String_toOffsetTime parses valid ISO-8601 extended time and offset strings by default`() { assertEquals( Time(23, 1, 1, 1) at UtcOffset(1.hours), "23:01:01.000000001+01".toOffsetTime() @@ -195,7 +195,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetTime() parses valid ISO-8601 basic time and offset strings with explicit parser`() { + fun `String_toOffsetTime parses valid ISO-8601 basic time and offset strings with explicit parser`() { assertEquals( Time(23, 1, 1, 1) at UtcOffset(1.hours), "230101.000000001+01".toOffsetTime(DateTimeParsers.Iso.Basic.OFFSET_TIME) @@ -207,7 +207,7 @@ class OffsetTimeTest : AbstractIslandTimeTest() { } @Test - fun `adjustedTo() changes the offset while preserving the instant represented by it`() { + fun `adjustedTo changes the offset while preserving the instant represented by it`() { assertEquals( Time(7, 0) at UtcOffset.MIN, Time(1, 0).at(UtcOffset.ZERO).adjustedTo(UtcOffset.MIN) diff --git a/core/src/commonTest/kotlin/io/islandtime/TimeTest.kt b/core/src/commonTest/kotlin/io/islandtime/TimeTest.kt index 8f514c461..fc1e139e0 100644 --- a/core/src/commonTest/kotlin/io/islandtime/TimeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/TimeTest.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalTime::class) - package io.islandtime import io.islandtime.internal.NANOSECONDS_PER_DAY @@ -11,7 +9,9 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue -import kotlin.time.ExperimentalTime +import kotlin.time.Duration.Companion.days as kotlinDays +import kotlin.time.Duration.Companion.hours as kotlinHours +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds class TimeTest : AbstractIslandTimeTest() { @Test @@ -39,19 +39,19 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `Time_fromSecondOfDay() throws an exception when the second value is invalid`() { + fun `Time_fromSecondOfDay throws an exception when the second value is invalid`() { assertFailsWith { Time.fromSecondOfDay(-1) } assertFailsWith { Time.fromSecondOfDay(SECONDS_PER_DAY) } } @Test - fun `Time_fromSecondOfDay() throws an exception when the nanosecond value is invalid`() { + fun `Time_fromSecondOfDay throws an exception when the nanosecond value is invalid`() { assertFailsWith { Time.fromSecondOfDay(0, -1) } assertFailsWith { Time.fromSecondOfDay(0, 1_000_000_000) } } @Test - fun `Time_fromSecondOfDay() creates a Time from a second of the day value`() { + fun `Time_fromSecondOfDay creates a Time from a second of the day value`() { assertEquals( Time(1, 1, 1, 1), Time.fromSecondOfDay(3661, 1) @@ -59,13 +59,13 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `Time_fromNanosecondOfDay() throws an exception when the nanosecond value is invalid`() { + fun `Time_fromNanosecondOfDay throws an exception when the nanosecond value is invalid`() { assertFailsWith { Time.fromNanosecondOfDay(-1L) } assertFailsWith { Time.fromNanosecondOfDay(NANOSECONDS_PER_DAY) } } @Test - fun `Time_fromNanosecondOfDay() creates a Time from a nanosecond of the day value`() { + fun `Time_fromNanosecondOfDay creates a Time from a nanosecond of the day value`() { assertEquals( Time(0, 0, 1, 1), Time.fromNanosecondOfDay(1_000_000_001L) @@ -105,27 +105,27 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 extended time with minute precision`() { + fun `toString returns an ISO-8601 extended time with minute precision`() { assertEquals("00:00", Time(0, 0, 0, 0).toString()) } @Test - fun `toString() returns an ISO-8601 extended time with second precision`() { + fun `toString returns an ISO-8601 extended time with second precision`() { assertEquals("01:01:01", Time(1, 1, 1, 0).toString()) } @Test - fun `toString() returns an ISO-8601 extended time with millisecond precision`() { + fun `toString returns an ISO-8601 extended time with millisecond precision`() { assertEquals("01:01:01.100", Time(1, 1, 1, 100_000_000).toString()) } @Test - fun `toString() returns an ISO-8601 extended time with microsecond precision`() { + fun `toString returns an ISO-8601 extended time with microsecond precision`() { assertEquals("23:59:59.000990", Time(23, 59, 59, 990_000).toString()) } @Test - fun `toString() returns an ISO-8601 extended time with nanosecond precision`() { + fun `toString returns an ISO-8601 extended time with nanosecond precision`() { assertEquals( "23:59:59.000000900", Time(23, 59, 59, 900).toString() @@ -142,7 +142,7 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() returns a Time with altered values`() { + fun `copy returns a Time with altered values`() { assertEquals(Time(3, 30), Time(9, 30).copy(hour = 3)) assertEquals(Time(9, 1), Time(9, 30).copy(minute = 1)) assertEquals(Time(9, 30, 3), Time(9, 30).copy(second = 3)) @@ -199,9 +199,7 @@ class TimeTest : AbstractIslandTimeTest() { assertEquals( Time(0, 0, 0, 2), Time(23, 0, 0, 1) + - (kotlin.time.Duration.days(2) + - kotlin.time.Duration.hours(1) + - kotlin.time.Duration.nanoseconds(1)) + (2.kotlinDays + 1.kotlinHours + 1.kotlinNanoseconds) ) } @@ -222,9 +220,7 @@ class TimeTest : AbstractIslandTimeTest() { assertEquals( Time(22, 0, 0, 0), Time(23, 0, 0, 1) - - (kotlin.time.Duration.days(2) + - kotlin.time.Duration.hours(1) + - kotlin.time.Duration.nanoseconds(1)) + (2.kotlinDays + 1.kotlinHours + 1.kotlinNanoseconds) ) } @@ -471,18 +467,18 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toTime() throws an exception when given an empty string`() { + fun `String_toTime throws an exception when given an empty string`() { assertFailsWith { "".toTime() } assertFailsWith { "".toTime(DateTimeParsers.Iso.TIME) } } @Test - fun `String_toTime() throws an exception when the parser can't supply all required fields`() { + fun `String_toTime throws an exception when the parser can't supply all required fields`() { assertFailsWith { "14".toTime(dateTimeParser { minuteOfHour(2) }) } } @Test - fun `String_toTime() throws an exception if parsed values cause overflow`() { + fun `String_toTime throws an exception if parsed values cause overflow`() { val parser = dateTimeParser { hourOfDay() +':' @@ -497,7 +493,7 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toTime() parses valid ISO-8601 extended time strings by default`() { + fun `String_toTime parses valid ISO-8601 extended time strings by default`() { assertEquals(Time(2, 0), "02".toTime()) assertEquals(Time(23, 0), "23:00".toTime()) assertEquals(Time(23, 30, 5), "23:30:05".toTime()) @@ -505,7 +501,7 @@ class TimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toTime() parses valid strings with explicit parser`() { + fun `String_toTime parses valid strings with explicit parser`() { assertEquals(Time(2, 0), "02".toTime(DateTimeParsers.Iso.Basic.TIME)) assertEquals(Time(23, 0), "2300".toTime(DateTimeParsers.Iso.Basic.TIME)) assertEquals(Time(23, 30, 5), "233005".toTime(DateTimeParsers.Iso.Basic.TIME)) diff --git a/core/src/commonTest/kotlin/io/islandtime/TimeZoneTest.kt b/core/src/commonTest/kotlin/io/islandtime/TimeZoneTest.kt index 7dc723e10..47200c8eb 100644 --- a/core/src/commonTest/kotlin/io/islandtime/TimeZoneTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/TimeZoneTest.kt @@ -64,19 +64,19 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `can be created from a region id, regardless of validity`() { + fun `can be created from a region id regardless of validity`() { listOf("Etc/UTC", "America/New_York", "America/Boston").forEach { assertEquals(TimeZone.Region(it), TimeZone(it)) } } @Test - fun `validated() throws an exception if a region-based time zone has an invalid ID`() { + fun `validated throws an exception if a region-based time zone has an invalid ID`() { assertFailsWith { TimeZone("America/Boston").validated() } } @Test - fun `validated() does nothing if the time zone is valid`() { + fun `validated does nothing if the time zone is valid`() { listOf( "America/New_York", "+18:00", @@ -88,7 +88,7 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `localizedName() and displayName() get localized text from the provider`() { + fun `localizedName and displayName get localized text from the provider`() { assertEquals( "Greenwich Mean Time", TimeZone("Europe/London").localizedName(TimeZoneTextStyle.STANDARD, "en-GB".toLocale()) @@ -100,7 +100,7 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `displayName() returns the ID on a fixed offset zone`() { + fun `displayName returns the ID on a fixed offset zone`() { assertEquals( "+01:00", TimeZone("+01:00").displayName(TimeZoneTextStyle.STANDARD, "en-GB".toLocale()) @@ -108,7 +108,7 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `displayName() returns the ID on an invalid zone`() { + fun `displayName returns the ID on an invalid zone`() { assertEquals( "America/Buffalo", TimeZone("America/Buffalo").displayName(TimeZoneTextStyle.STANDARD, "en-US".toLocale()) @@ -116,7 +116,7 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `normalized() turns a fixed region-based zone into a fixed offset zone`() { + fun `normalized turns a fixed region-based zone into a fixed offset zone`() { mapOf( "Etc/UTC" to UtcOffset.ZERO, "Etc/GMT+6" to UtcOffset((-6).hours), @@ -127,7 +127,7 @@ class TimeZoneTest : AbstractIslandTimeTest() { } @Test - fun `normalized() doesn't touch a fixed region-based zone`() { + fun `normalized doesn't touch a fixed region-based zone`() { listOf( "+00:00", "-05:00", diff --git a/core/src/commonTest/kotlin/io/islandtime/UtcOffsetTest.kt b/core/src/commonTest/kotlin/io/islandtime/UtcOffsetTest.kt index 8c5c9fedd..3480eaa2c 100644 --- a/core/src/commonTest/kotlin/io/islandtime/UtcOffsetTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/UtcOffsetTest.kt @@ -8,7 +8,7 @@ import kotlin.test.* class UtcOffsetTest : AbstractIslandTimeTest() { @Test - fun `UtcOffset() requires all values to have the same sign`() { + fun `UtcOffset requires all values to have the same sign`() { assertFailsWith { UtcOffset((-2).hours, 30.minutes) } assertFailsWith { UtcOffset((-2).hours, (-30).minutes, 5.seconds) } assertFailsWith { UtcOffset((-2).hours, 30.minutes, (-5).seconds) } @@ -20,7 +20,7 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `UtcOffset() requires each component to be valid individually`() { + fun `UtcOffset requires each component to be valid individually`() { assertFailsWith { UtcOffset(19.hours) } assertFailsWith { UtcOffset(2.hours, 60.minutes) } assertFailsWith { UtcOffset((-2).hours, (-60).minutes) } @@ -29,7 +29,7 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `UtcOffset() creates an offset with the sum of all components`() { + fun `UtcOffset creates an offset with the sum of all components`() { assertEquals(3_600.seconds, UtcOffset(1.hours).totalSeconds) assertEquals(3_660.seconds, UtcOffset(1.hours, 1.minutes).totalSeconds) assertEquals((-3_660).seconds, UtcOffset((-1).hours, (-1).minutes).totalSeconds) @@ -43,32 +43,32 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `Hours_asUtcOffset() creates a UtcOffset from a duration of hours`() { + fun `Hours_asUtcOffset creates a UtcOffset from a duration of hours`() { assertEquals((-3600).seconds, (-1).hours.asUtcOffset().totalSeconds) } @Test - fun `Hours_asUtcOffset() throws an exception on overflow`() { + fun `Hours_asUtcOffset throws an exception on overflow`() { assertFailsWith { Int.MAX_VALUE.hours.asUtcOffset() } } @Test - fun `Minutes_asUtcOffset() creates a UtcOffset from a duration of minutes`() { + fun `Minutes_asUtcOffset creates a UtcOffset from a duration of minutes`() { assertEquals((-12_000).seconds, (-200).minutes.asUtcOffset().totalSeconds) } @Test - fun `Minutes_asUtcOffset() throws an exception on overflow`() { + fun `Minutes_asUtcOffset throws an exception on overflow`() { assertFailsWith { Int.MAX_VALUE.minutes.asUtcOffset() } } @Test - fun `Seconds_asUtcOffset() creates a UtcOffset from a duration of seconds`() { + fun `Seconds_asUtcOffset creates a UtcOffset from a duration of seconds`() { assertEquals(1.seconds, 1.seconds.asUtcOffset().totalSeconds) } @Test - fun `isZero() returns true only when the offset is zero`() { + fun `isZero returns true only when the offset is zero`() { assertTrue { UtcOffset(0.seconds).isZero() } assertFalse { UtcOffset((-1).seconds).isZero() } } @@ -92,7 +92,7 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `toComponents() breaks an offset down into hours, minutes, and seconds`() { + fun `toComponents breaks an offset down into hours + minutes + seconds`() { UtcOffset((-1).hours, (-30).minutes).toComponents { hours, minutes, seconds -> assertEquals((-1).hours, hours) assertEquals((-30).minutes, minutes) @@ -101,7 +101,7 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `toComponents() breaks a time offset down into sign, hours, minutes, and seconds`() { + fun `toComponents breaks a time offset down into sign + hours + minutes + seconds`() { UtcOffset((-1).hours, (-30).minutes).toComponents { sign, hours, minutes, seconds -> assertEquals(-1, sign) assertEquals(1.hours, hours) @@ -111,12 +111,12 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns 'Z' when the offset is zero`() { + fun `toString returns 'Z' when the offset is zero`() { assertEquals("Z", UtcOffset.ZERO.toString()) } @Test - fun `toString() returns an ISO-8601 time offset string for non-zero offsets`() { + fun `toString returns an ISO-8601 time offset string for non-zero offsets`() { assertEquals("+02:00", UtcOffset(2.hours).toString()) assertEquals("-02:00", UtcOffset((-2).hours).toString()) assertEquals("+02:30", UtcOffset(2.hours, 30.minutes).toString()) @@ -124,12 +124,12 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `String_toUtcOffset() throws an exception with empty strings`() { + fun `String_toUtcOffset throws an exception with empty strings`() { assertFailsWith { "".toUtcOffset() } } @Test - fun `String_toUtcOffset() throws an exception with invalid ISO-8601 offsets`() { + fun `String_toUtcOffset throws an exception with invalid ISO-8601 offsets`() { assertFailsWith { "01:00".toUtcOffset() } assertFailsWith { "--01:00".toUtcOffset() } assertFailsWith { "+1:00".toUtcOffset() } @@ -137,17 +137,17 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `String_toUtcOffset() throws an exception when the parser can't supplied all required fields`() { + fun `String_toUtcOffset throws an exception when the parser can't supplied all required fields`() { assertFailsWith { "04".toUtcOffset(DateTimeParsers.Iso.TIME) } } @Test - fun `String_toUtcOffset() parses zero offsets indicated by 'Z'`() { + fun `String_toUtcOffset parses zero offsets indicated by 'Z'`() { assertEquals(UtcOffset.ZERO, "Z".toUtcOffset()) } @Test - fun `String_toUtcOffset() parses valid ISO-8601 extended time offset strings`() { + fun `String_toUtcOffset parses valid ISO-8601 extended time offset strings`() { assertEquals( UtcOffset(1.hours), "+01".toUtcOffset() @@ -170,7 +170,7 @@ class UtcOffsetTest : AbstractIslandTimeTest() { } @Test - fun `String_toUtcOffset() parses valid ISO-8601 basic time offsets with explicit parser`() { + fun `String_toUtcOffset parses valid ISO-8601 basic time offsets with explicit parser`() { assertEquals( UtcOffset(1.hours), "+01".toUtcOffset(DateTimeParsers.Iso.UTC_OFFSET) diff --git a/core/src/commonTest/kotlin/io/islandtime/WeekDateTest.kt b/core/src/commonTest/kotlin/io/islandtime/WeekDateTest.kt index d210eefba..e0779517a 100644 --- a/core/src/commonTest/kotlin/io/islandtime/WeekDateTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/WeekDateTest.kt @@ -13,14 +13,14 @@ class WeekDateTest : AbstractIslandTimeTest() { private val en_US = "en-US".toLocale() @Test - fun `Date_toWeekDate() converts to ISO week date`() { + fun `Date_toWeekDate converts to ISO week date`() { TestData.isoWeekDates.forEach { (date, weekDate) -> assertEquals(weekDate, date.toWeekDate(::Triple), date.toString()) } } @Test - fun `Date_toWeekDate() converts to week date with Sunday start week definition`() { + fun `Date_toWeekDate converts to week date with Sunday start week definition`() { TestData.sundayStartWeekDates.forEach { (date, weekDate) -> assertEquals(weekDate, date.toWeekDate(SUNDAY_START, ::Triple), message = "$date (SUNDAY_START)") assertEquals(weekDate, date.toWeekDate(en_US, ::Triple), message = "$date (en-US)") @@ -28,13 +28,13 @@ class WeekDateTest : AbstractIslandTimeTest() { } @Test - fun `Date_fromWeekDate() throws an exception when year is out of range`() { + fun `Date_fromWeekDate throws an exception when year is out of range`() { assertFailsWith { Date.fromWeekDate(Year.MIN_VALUE - 1, 52, 1) } assertFailsWith { Date.fromWeekDate(Year.MAX_VALUE + 1, 1, 1) } } @Test - fun `Date_fromWeekDate(settings) throws an exception when year is out of range`() { + fun `Date_fromWeekDate with settings throws an exception when year is out of range`() { assertFailsWith { Date.fromWeekDate(Year.MIN_VALUE - 1, 52, 1, SUNDAY_START) } @@ -44,32 +44,32 @@ class WeekDateTest : AbstractIslandTimeTest() { } @Test - fun `Date_fromWeekDate() throws an exception when week is out of range`() { + fun `Date_fromWeekDate throws an exception when week is out of range`() { assertFailsWith { Date.fromWeekDate(2000, 0, 1) } assertFailsWith { Date.fromWeekDate(2010, 53, 1) } assertFailsWith { Date.fromWeekDate(2010, 54, 1) } } @Test - fun `Date_fromWeekDate(settings) throws an exception when week is out of range`() { + fun `Date_fromWeekDate with settings throws an exception when week is out of range`() { assertFailsWith { Date.fromWeekDate(2000, 0, 1, SUNDAY_START) } assertFailsWith { Date.fromWeekDate(2010, 54, 1, SUNDAY_START) } } @Test - fun `Date_fromWeekDate() throws an exception when day is out of range`() { + fun `Date_fromWeekDate throws an exception when day is out of range`() { assertFailsWith { Date.fromWeekDate(2000, 23, 0) } assertFailsWith { Date.fromWeekDate(2010, 35, 8) } } @Test - fun `Date_fromWeekDate(settings) throws an exception when day is out of range`() { + fun `Date_fromWeekDate with settings throws an exception when day is out of range`() { assertFailsWith { Date.fromWeekDate(2000, 23, 0, SUNDAY_START) } assertFailsWith { Date.fromWeekDate(2010, 35, 8, SUNDAY_START) } } @Test - fun `Date_fromWeekDate() creates a Date from an ISO week date`() { + fun `Date_fromWeekDate creates a Date from an ISO week date`() { TestData.isoWeekDates.forEach { (date, weekDate) -> val (year, week, day) = weekDate assertEquals(date, Date.fromWeekDate(year, week, day), date.toString()) @@ -77,7 +77,7 @@ class WeekDateTest : AbstractIslandTimeTest() { } @Test - fun `Date_fromWeekDate() creates a Date from a Sunday start week date`() { + fun `Date_fromWeekDate creates a Date from a Sunday start week date`() { TestData.sundayStartWeekDates.filter { it.first != Date.MAX }.forEach { (date, weekDate) -> val (year, week, day) = weekDate assertEquals(date, Date.fromWeekDate(year, week, day, SUNDAY_START), message = "$date (SUNDAY_START)") diff --git a/core/src/commonTest/kotlin/io/islandtime/YearMonthTest.kt b/core/src/commonTest/kotlin/io/islandtime/YearMonthTest.kt index 8dc129bbe..dcea19275 100644 --- a/core/src/commonTest/kotlin/io/islandtime/YearMonthTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/YearMonthTest.kt @@ -72,7 +72,7 @@ class YearMonthTest : AbstractIslandTimeTest() { } @Test - fun `copy() can be used to replace the year or month component`() { + fun `copy can be used to replace the year or month component`() { assertEquals( YearMonth(1999, Month.DECEMBER), YearMonth(2000, Month.DECEMBER).copy(year = 1999) @@ -90,7 +90,7 @@ class YearMonthTest : AbstractIslandTimeTest() { } @Test - fun `copy() throws an exception if the new year is invalid`() { + fun `copy throws an exception if the new year is invalid`() { assertFailsWith { YearMonth(2010, Month.DECEMBER).copy(year = -1_000_000_000) } @@ -466,7 +466,7 @@ class YearMonthTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 year month representation`() { + fun `toString returns an ISO-8601 year month representation`() { listOf( YearMonth(2000, Month.FEBRUARY) to "2000-02", YearMonth(9999, Month.DECEMBER) to "9999-12", @@ -484,12 +484,12 @@ class YearMonthTest : AbstractIslandTimeTest() { } @Test - fun `String_toYearMonth() throws an exception when parsing an empty string`() { + fun `String_toYearMonth throws an exception when parsing an empty string`() { assertFailsWith { "".toYearMonth() } } @Test - fun `String_toYearMonth() throws an exception when parsing an invalid ISO-8601 extended string`() { + fun `String_toYearMonth throws an exception when parsing an invalid ISO-8601 extended string`() { listOf( "2012-05-01", "201205", @@ -504,21 +504,21 @@ class YearMonthTest : AbstractIslandTimeTest() { } @Test - fun `String_toYearMonth() throws an exception when the year is out of range`() { + fun `String_toYearMonth throws an exception when the year is out of range`() { listOf("+1000000000-01", "-1000000000-12").forEach { assertFailsWith { it.toYearMonth() } } } @Test - fun `String_toYearMonth() throws an exception when the month is out of range`() { + fun `String_toYearMonth throws an exception when the month is out of range`() { listOf("0001-13", "0001-00").forEach { assertFailsWith { it.toYearMonth() } } } @Test - fun `String_toYearMonth() parses ISO-8601 year months by default`() { + fun `String_toYearMonth parses ISO-8601 year months by default`() { listOf( "2012-05" to YearMonth(2012, Month.MAY), "9999-12" to YearMonth(9999, Month.DECEMBER), diff --git a/core/src/commonTest/kotlin/io/islandtime/YearTest.kt b/core/src/commonTest/kotlin/io/islandtime/YearTest.kt index f6d3e29d9..298df7396 100644 --- a/core/src/commonTest/kotlin/io/islandtime/YearTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/YearTest.kt @@ -317,7 +317,7 @@ class YearTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns the year with a minimum of 4 digits as required by ISO-8601`() { + fun `toString returns the year with a minimum of 4 digits as required by ISO-8601`() { listOf( 2008 to "2008", 1 to "0001", @@ -335,12 +335,12 @@ class YearTest : AbstractIslandTimeTest() { } @Test - fun `String_toYear() throws an exception when the string is empty`() { + fun `String_toYear throws an exception when the string is empty`() { assertFailsWith { "".toYear() } } @Test - fun `String_toYear() throws an exception when parsing an improperly formatted string`() { + fun `String_toYear throws an exception when parsing an improperly formatted string`() { listOf( "1", "01", @@ -362,7 +362,7 @@ class YearTest : AbstractIslandTimeTest() { } @Test - fun `String_toYear() throws an exception when the year is outside the supported range`() { + fun `String_toYear throws an exception when the year is outside the supported range`() { val customParser = dateTimeParser { year() } listOf( @@ -376,7 +376,7 @@ class YearTest : AbstractIslandTimeTest() { } @Test - fun `String_toYear() converts an ISO-8601 year string to a Year`() { + fun `String_toYear converts an ISO-8601 year string to a Year`() { listOf( "2010" to 2010, "0001" to 1, @@ -398,7 +398,7 @@ class YearTest : AbstractIslandTimeTest() { } @Test - fun `String_toYear() throws an exception when the parser fails to supply the YEAR field`() { + fun `String_toYear throws an exception when the parser fails to supply the YEAR field`() { val customParser = dateTimeParser { monthNumber(2) } assertFailsWith { "12".toYear(customParser) } } diff --git a/core/src/commonTest/kotlin/io/islandtime/ZonedDateTimeTest.kt b/core/src/commonTest/kotlin/io/islandtime/ZonedDateTimeTest.kt index 619f692df..b8726be57 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ZonedDateTimeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ZonedDateTimeTest.kt @@ -22,7 +22,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `when constructed from a DateTime that falls in an overlap, the earlier offset is used by default`() { + fun `when constructed from a DateTime that falls in an overlap the earlier offset is used by default`() { val actual = ZonedDateTime( DateTime(2019, 11, 3, 1, 0), nyZone @@ -34,7 +34,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `when constructed from a DateTime that falls in an overlap, a preferred offset may be provided`() { + fun `when constructed from a DateTime that falls in an overlap a preferred offset may be provided`() { val actual = ZonedDateTime.fromLocal( DateTime(2019, 11, 3, 1, 0), nyZone, @@ -47,7 +47,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `when constructed from a DateTime that falls in an overlap, an invalid preferred offset is ignored`() { + fun `when constructed from a DateTime that falls in an overlap an invalid preferred offset is ignored`() { val actual = ZonedDateTime.fromLocal( DateTime(2019, 11, 3, 1, 0), nyZone, @@ -60,7 +60,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `when constructed from a DateTime that doesn't fall in an overlap, the preferred offset is ignored`() { + fun `when constructed from a DateTime that doesn't fall in an overlap the preferred offset is ignored`() { val actual = ZonedDateTime.fromLocal( DateTime(2019, 11, 3, 2, 0), nyZone, @@ -73,7 +73,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `when constructed from a DateTime that falls during a gap, the DateTime is adjusted by the gap's length`() { + fun `when constructed from a DateTime that falls during a gap the DateTime is adjusted by the gap's length`() { val actual = ZonedDateTime( DateTime(2019, 3, 10, 2, 30), nyZone @@ -171,7 +171,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `equality is based on date-time, time zone, and offset`() { + fun `equality is based on date-time + time zone + offset`() { assertEquals( ZonedDateTime.create( DateTime(2019, 11, 3, 1, 0), @@ -211,7 +211,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `DefaultSortOrder compares based on instant, then date and time, and then zone`() { + fun `DefaultSortOrder compares based on instant then date and time and then zone`() { assertTrue { ZonedDateTime.DefaultSortOrder.compare( Date(1969, 365) at Time(23, 0) at TimeZone("America/Chicago"), @@ -245,7 +245,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `compareTo() compares based on instant only`() { + fun `compareTo compares based on instant only`() { assertTrue { Date(1969, 365) at Time(22, 0) at UtcOffset((-1).hours) < Date(1970, 1) at Time(0, 0) at UtcOffset.ZERO @@ -266,7 +266,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() ignores changes to the offset if it isn't valid for the time zone`() { + fun `copy ignores changes to the offset if it isn't valid for the time zone`() { assertEquals( ZonedDateTime.create( DateTime(2019, 3, 3, 7, 0), @@ -285,7 +285,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() adjusts components forward when rendered invalid due to gaps`() { + fun `copy adjusts components forward when rendered invalid due to gaps`() { assertEquals( ZonedDateTime.create( DateTime(2019, 3, 10, 3, 3), @@ -300,7 +300,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `copy() replaces components directly with new values when it's possible to do so`() { + fun `copy replaces components directly with new values when it's possible to do so`() { assertEquals( ZonedDateTime.create( DateTime(2018, 3, 10, 3, 0), @@ -315,7 +315,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withEarlierOffsetAtOverlap() returns the same DateTime with the earlier offset when there's a DST overlap`() { + fun `withEarlierOffsetAtOverlap returns the same DateTime with the earlier offset when there's a DST overlap`() { assertEquals( ZonedDateTime.create( DateTime(2019, 11, 3, 1, 30), @@ -331,7 +331,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withEarlierOffsetAtOverlap() returns the same ZonedDateTime when there's no overlap`() { + fun `withEarlierOffsetAtOverlap returns the same ZonedDateTime when there's no overlap`() { assertEquals( ZonedDateTime( DateTime(2019, 11, 3, 2, 30), @@ -345,7 +345,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withLaterOffsetAtOverlap() returns the same DateTime with the later offset when there's a DST overlap`() { + fun `withLaterOffsetAtOverlap returns the same DateTime with the later offset when there's a DST overlap`() { assertEquals( ZonedDateTime.create( DateTime(2019, 11, 3, 1, 30), @@ -361,7 +361,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withLaterOffsetAtOverlap() returns the same ZonedDateTime when there's no overlap`() { + fun `withLaterOffsetAtOverlap returns the same ZonedDateTime when there's no overlap`() { assertEquals( ZonedDateTime( DateTime(2019, 11, 3, 2, 30), @@ -375,7 +375,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withFixedOffsetZone() returns the same ZonedDateTime if it already has a fixed zone`() { + fun `withFixedOffsetZone returns the same ZonedDateTime if it already has a fixed zone`() { assertEquals( ZonedDateTime( DateTime(2019, 11, 4, 8, 30), @@ -389,7 +389,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `withFixedOffsetZone() returns a ZonedDateTime with a fixed offset zone when region-based`() { + fun `withFixedOffsetZone returns a ZonedDateTime with a fixed offset zone when region-based`() { assertEquals( ZonedDateTime( DateTime(2019, 11, 4, 8, 30), @@ -403,7 +403,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `adjustedTo() converts to a different time zone while preserving the instant during overlap`() { + fun `adjustedTo converts to a different time zone while preserving the instant during overlap`() { // New York in overlap, Denver not in overlap assertEquals( ZonedDateTime.create( @@ -448,7 +448,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `adjustedTo() converts to a different time zone while preserving the instant during gaps`() { + fun `adjustedTo converts to a different time zone while preserving the instant during gaps`() { // New York in DST, Denver not yet assertEquals( ZonedDateTime.create( @@ -483,7 +483,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `adding a period first adds years, then months, then days`() { + fun `adding a period adds years then months then days`() { assertEquals( DateTime(2017, Month.MARCH, 29, 9, 0) at nyZone, (DateTime(2016, Month.FEBRUARY, 29, 9, 0) at nyZone) + @@ -504,7 +504,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `subtracting a period first subtracts years, then months, then days`() { + fun `subtracting a period subtracts years then months then days`() { assertEquals( DateTime(2017, Month.MARCH, 29, 9, 0) at nyZone, (DateTime(2016, Month.FEBRUARY, 29, 9, 0) at nyZone) - @@ -519,7 +519,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 extended offset date-time along with a non-standard region ID`() { + fun `toString returns an ISO-8601 extended offset date-time along with a non-standard region ID`() { assertEquals( "2019-11-03T01:30Z[Etc/UTC]", ZonedDateTime( @@ -539,12 +539,12 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toZonedDateTime() throws an exception when the string is empty`() { + fun `String_toZonedDateTime throws an exception when the string is empty`() { assertFailsWith { "".toZonedDateTime() } } @Test - fun `String_toZonedDateTime() throws an exception when the format is unexpected`() { + fun `String_toZonedDateTime throws an exception when the format is unexpected`() { listOf( "2019-12-05T12:00+01:00[America/New_York ]", "2019-12-05T12:00+01:00America/New_York", @@ -562,7 +562,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toZonedDateTime() throws an exception when fields are out of range`() { + fun `String_toZonedDateTime throws an exception when fields are out of range`() { listOf( "2000-01-01T24:00Z[Etc/Utc]", "2000-01-01T08:60-01:00[GMT+1]", @@ -574,7 +574,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toZonedDateTime() throws an exception if the parsed zone isn't valid`() { + fun `String_toZonedDateTime throws an exception if the parsed zone isn't valid`() { listOf( "2000-01-01T23:00+01:00[America/Boston]", "2000-01-01T23:00+01:00[Etc/GMT-20]" @@ -584,7 +584,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toZonedDateTime() parses ISO-8601 calendar date time strings in extended format by default`() { + fun `String_toZonedDateTime parses ISO-8601 calendar date time strings in extended format by default`() { assertEquals( ZonedDateTime.create( DateTime(Date(2019, Month.MAY, 5), Time.NOON), @@ -614,7 +614,7 @@ class ZonedDateTimeTest : AbstractIslandTimeTest() { } @Test - fun `String_toZonedDateTime() parses valid ISO-8601 strings with explicit parser`() { + fun `String_toZonedDateTime parses valid ISO-8601 strings with explicit parser`() { assertEquals( ZonedDateTime.create( DateTime(Date(2019, Month.MAY, 5), Time.NOON), diff --git a/core/src/commonTest/kotlin/io/islandtime/clock/ClockTest.kt b/core/src/commonTest/kotlin/io/islandtime/clock/ClockTest.kt index 8153ab525..cc407cc67 100644 --- a/core/src/commonTest/kotlin/io/islandtime/clock/ClockTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/clock/ClockTest.kt @@ -19,7 +19,7 @@ class ClockTest { } @Test - fun `SystemClock() without zone`() { + fun `SystemClock without zone`() { val clock = SystemClock() assertTrue { clock.readMilliseconds() > 0L.milliseconds } @@ -28,7 +28,7 @@ class ClockTest { } @Test - fun `SystemClock() with zone`() { + fun `SystemClock with zone`() { val clock = SystemClock(TimeZone("America/Denver")) assertTrue { clock.readMilliseconds() > 0L.milliseconds } diff --git a/core/src/commonTest/kotlin/io/islandtime/clock/NowTest.kt b/core/src/commonTest/kotlin/io/islandtime/clock/NowTest.kt index ceeb1bc66..3569d8c16 100644 --- a/core/src/commonTest/kotlin/io/islandtime/clock/NowTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/clock/NowTest.kt @@ -10,7 +10,7 @@ import kotlin.test.assertEquals class NowTest : AbstractIslandTimeTest() { @Test - fun `Year_now()`() { + fun Year_now() { val clock = FixedClock(Instant((-1L).milliseconds), TimeZone.UTC) assertEquals(Year(1969), Year.now(clock)) @@ -19,7 +19,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `YearMonth_now()`() { + fun YearMonth_now() { val clock = FixedClock(Instant((-1L).milliseconds), TimeZone.UTC) assertEquals(YearMonth(1969, Month.DECEMBER), YearMonth.now(clock)) @@ -28,7 +28,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `Date_now() in UTC`() { + fun `Date_now in UTC`() { val clock = FixedClock(Instant((-1L).milliseconds), TimeZone.UTC) assertEquals(Date(1969, Month.DECEMBER, 31), Date.now(clock)) @@ -37,13 +37,13 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `Date_now() with offset`() { + fun `Date_now with offset`() { val clock = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+1")) assertEquals(Date(1969, Month.DECEMBER, 30), Date.now(clock)) } @Test - fun `DateTime_now() in UTC`() { + fun `DateTime_now in UTC`() { val clock = FixedClock(Instant((-1L).milliseconds), TimeZone.UTC) assertEquals( DateTime(1969, Month.DECEMBER, 31, 23, 59, 59, 999_000_000), @@ -64,7 +64,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_now() with offset`() { + fun `DateTime_now with offset`() { val clock = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+1")) assertEquals( DateTime(1969, Month.DECEMBER, 30, 23, 0), @@ -73,7 +73,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `Time_now() in UTC`() { + fun `Time_now in UTC`() { val clock = FixedClock(Instant((-1L).days.inSeconds), TimeZone.UTC) assertEquals(Time(0, 0), Time.now(clock)) @@ -91,7 +91,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `Time_now() with offset`() { + fun `Time_now with offset`() { val clock1 = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+4")) assertEquals(Time(20, 0), Time.now(clock1)) @@ -100,7 +100,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `OffsetTime_now()`() { + fun OffsetTime_now() { val clock1 = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+4")) assertEquals(OffsetTime(Time(20, 0), (-4).hours.asUtcOffset()), OffsetTime.now(clock1)) @@ -109,7 +109,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_now()`() { + fun OffsetDateTime_now() { val clock = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+1")) assertEquals( OffsetDateTime( @@ -130,7 +130,7 @@ class NowTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_now()`() { + fun ZonedDateTime_now() { val clock = FixedClock(Instant((-1L).days.inSeconds), TimeZone("Etc/GMT+1")) assertEquals( ZonedDateTime( diff --git a/core/src/commonTest/kotlin/io/islandtime/format/DateTimeTextProviderTest.kt b/core/src/commonTest/kotlin/io/islandtime/format/DateTimeTextProviderTest.kt index 53759d97a..d12cf7eb4 100644 --- a/core/src/commonTest/kotlin/io/islandtime/format/DateTimeTextProviderTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/format/DateTimeTextProviderTest.kt @@ -13,7 +13,7 @@ class DateTimeTextProviderTest : AbstractIslandTimeTest() { private val pl_PL = "pl-PL".toLocale() @Test - fun `textFor() throws an exception when value is out of range`() { + fun `textFor throws an exception when value is out of range`() { assertFailsWith { DateTimeTextProvider.textFor(DateTimeField.MONTH_OF_YEAR, 0L, TextStyle.FULL, en_US) } @@ -41,18 +41,18 @@ class DateTimeTextProviderTest : AbstractIslandTimeTest() { } @Test - fun `textFor() returns null when the field has no text representation`() { + fun `textFor returns null when the field has no text representation`() { assertNull(DateTimeTextProvider.textFor(DateTimeField.DAY_OF_MONTH, 1L, TextStyle.FULL, en_US)) assertNull(DateTimeTextProvider.textFor(DateTimeField.YEAR, 2010L, TextStyle.FULL, en_US)) } @Test - fun `parsableTextFor() returns an empty list when no styles are specified`() { + fun `parsableTextFor returns an empty list when no styles are specified`() { assertTrue { DateTimeTextProvider.parsableTextFor(DateTimeField.DAY_OF_WEEK, emptySet(), en_US).isEmpty() } } @Test - fun `parsableTextFor() returns an empty list when the field has no text representation`() { + fun `parsableTextFor returns an empty list when the field has no text representation`() { assertTrue { DateTimeTextProvider.parsableTextFor(DateTimeField.DAY_OF_MONTH, TextStyle.FULL, en_US).isEmpty() } diff --git a/core/src/commonTest/kotlin/io/islandtime/format/TextStyleTest.kt b/core/src/commonTest/kotlin/io/islandtime/format/TextStyleTest.kt index 7d8b80e09..4602536f0 100644 --- a/core/src/commonTest/kotlin/io/islandtime/format/TextStyleTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/format/TextStyleTest.kt @@ -7,21 +7,21 @@ import kotlin.test.assertTrue class TextStyleTest { @Test - fun `TextStyle_isStandalone() returns true for standalone styles`() { + fun `TextStyle_isStandalone returns true for standalone styles`() { assertTrue { TextStyle.FULL_STANDALONE.isStandalone() } assertTrue { TextStyle.SHORT_STANDALONE.isStandalone() } assertTrue { TextStyle.NARROW_STANDALONE.isStandalone() } } @Test - fun `TextStyle_isStandalone() returns false for normal styles`() { + fun `TextStyle_isStandalone returns false for normal styles`() { assertFalse { TextStyle.FULL.isStandalone() } assertFalse { TextStyle.SHORT.isStandalone() } assertFalse { TextStyle.NARROW.isStandalone() } } - + @Test - fun `TextStyle_asStandalone() returns a similar standalone style`() { + fun `TextStyle_asStandalone returns a similar standalone style`() { assertEquals(TextStyle.FULL_STANDALONE, TextStyle.FULL.asStandalone()) assertEquals(TextStyle.FULL_STANDALONE, TextStyle.FULL_STANDALONE.asStandalone()) assertEquals(TextStyle.SHORT_STANDALONE, TextStyle.SHORT.asStandalone()) @@ -31,7 +31,7 @@ class TextStyleTest { } @Test - fun `TextStyle_asNormal() returns a similar normal style`() { + fun `TextStyle_asNormal returns a similar normal style`() { assertEquals(TextStyle.FULL, TextStyle.FULL.asNormal()) assertEquals(TextStyle.FULL, TextStyle.FULL_STANDALONE.asNormal()) assertEquals(TextStyle.SHORT, TextStyle.SHORT.asNormal()) @@ -41,27 +41,27 @@ class TextStyleTest { } @Test - fun `TimeZoneTextStyle_isShort() returns true for short styles`() { + fun `TimeZoneTextStyle_isShort returns true for short styles`() { assertTrue { TimeZoneTextStyle.SHORT_STANDARD.isShort() } assertTrue { TimeZoneTextStyle.SHORT_DAYLIGHT_SAVING.isShort() } assertTrue { TimeZoneTextStyle.SHORT_GENERIC.isShort() } } @Test - fun `TimeZoneTextStyle_isShort() returns false for normal styles`() { + fun `TimeZoneTextStyle_isShort returns false for normal styles`() { assertFalse { TimeZoneTextStyle.STANDARD.isShort() } assertFalse { TimeZoneTextStyle.DAYLIGHT_SAVING.isShort() } assertFalse { TimeZoneTextStyle.GENERIC.isShort() } } - + @Test - fun `TimeZoneStyle_isStandard() returns true for standard styles`() { + fun `TimeZoneStyle_isStandard returns true for standard styles`() { assertTrue { TimeZoneTextStyle.STANDARD.isStandard() } assertTrue { TimeZoneTextStyle.SHORT_STANDARD.isStandard() } } @Test - fun `TimeZoneStyle_isStandard() returns false for non-standard styles`() { + fun `TimeZoneStyle_isStandard returns false for non-standard styles`() { assertFalse { TimeZoneTextStyle.DAYLIGHT_SAVING.isStandard() } assertFalse { TimeZoneTextStyle.SHORT_DAYLIGHT_SAVING.isStandard() } assertFalse { TimeZoneTextStyle.GENERIC.isStandard() } @@ -69,13 +69,13 @@ class TextStyleTest { } @Test - fun `TimeZoneStyle_isDaylightSaving() returns true for daylight saving styles`() { + fun `TimeZoneStyle_isDaylightSaving returns true for daylight saving styles`() { assertTrue { TimeZoneTextStyle.DAYLIGHT_SAVING.isDaylightSaving() } assertTrue { TimeZoneTextStyle.SHORT_DAYLIGHT_SAVING.isDaylightSaving() } } @Test - fun `TimeZoneStyle_isDaylightSaving() returns false for non-standard styles`() { + fun `TimeZoneStyle_isDaylightSaving returns false for non-standard styles`() { assertFalse { TimeZoneTextStyle.STANDARD.isDaylightSaving() } assertFalse { TimeZoneTextStyle.SHORT_STANDARD.isDaylightSaving() } assertFalse { TimeZoneTextStyle.GENERIC.isDaylightSaving() } @@ -83,13 +83,13 @@ class TextStyleTest { } @Test - fun `TimeZoneStyle_isGeneric() returns true for standard styles`() { + fun `TimeZoneStyle_isGeneric returns true for standard styles`() { assertTrue { TimeZoneTextStyle.GENERIC.isGeneric() } assertTrue { TimeZoneTextStyle.SHORT_GENERIC.isGeneric() } } @Test - fun `TimeZoneStyle_isGeneric() returns false for non-standard styles`() { + fun `TimeZoneStyle_isGeneric returns false for non-standard styles`() { assertFalse { TimeZoneTextStyle.STANDARD.isGeneric() } assertFalse { TimeZoneTextStyle.SHORT_STANDARD.isGeneric() } assertFalse { TimeZoneTextStyle.DAYLIGHT_SAVING.isGeneric() } diff --git a/core/src/commonTest/kotlin/io/islandtime/format/TimeZoneTextProviderTest.kt b/core/src/commonTest/kotlin/io/islandtime/format/TimeZoneTextProviderTest.kt index 205bfa993..8db9d2fb5 100644 --- a/core/src/commonTest/kotlin/io/islandtime/format/TimeZoneTextProviderTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/format/TimeZoneTextProviderTest.kt @@ -14,7 +14,7 @@ class TimeZoneTextProviderTest : AbstractIslandTimeTest() { private val de_DE = "de-DE".toLocale() @Test - fun `timeZoneTextFor() returns null when given a fixed offset time zone`() { + fun `timeZoneTextFor returns null when given a fixed offset time zone`() { listOf( TimeZone.FixedOffset("-04:00"), TimeZone.FixedOffset("+00:00"), @@ -28,7 +28,7 @@ class TimeZoneTextProviderTest : AbstractIslandTimeTest() { } @Test - fun `timeZoneTextFor() returns a localized string when available`() { + fun `timeZoneTextFor returns a localized string when available`() { val zone = TimeZone("America/New_York") assertEquals( @@ -50,7 +50,7 @@ class TimeZoneTextProviderTest : AbstractIslandTimeTest() { } @Test - fun `timeZoneTextFor() returns null when the zone is invalid`() { + fun `timeZoneTextFor returns null when the zone is invalid`() { val zone = TimeZone("America/Boston") assertFalse { zone.isValid } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/DaysTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/DaysTest.kt index e8a931524..738c0e227 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/DaysTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/DaysTest.kt @@ -3,8 +3,7 @@ package io.islandtime.measures import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -import kotlin.time.ExperimentalTime -import kotlin.time.Duration as KotlinDuration +import kotlin.time.Duration.Companion.days as kotlinDays class DaysTest { @Test @@ -15,31 +14,29 @@ class DaysTest { } @Test - fun `toString() converts zero days to 'P0D'`() { + fun `toString converts zero days to 'P0D'`() { assertEquals("P0D", 0.days.toString()) } @Test - fun `toString() converts to ISO-8601 period representation`() { + fun `toString converts to ISO-8601 period representation`() { assertEquals("P1D", 1.days.toString()) assertEquals("-P1D", (-1).days.toString()) } - @ExperimentalTime @Test fun `conversion to Kotlin Duration`() { - assertEquals(KotlinDuration.days(0), 0.days.toKotlinDuration()) - assertEquals(KotlinDuration.days(1), 1.days.toKotlinDuration()) - assertEquals(KotlinDuration.days(-1), (-1L).days.toKotlinDuration()) - assertEquals(KotlinDuration.days(Long.MIN_VALUE), Long.MIN_VALUE.days.toKotlinDuration()) + assertEquals(0.kotlinDays, 0.days.toKotlinDuration()) + assertEquals(1.kotlinDays, 1.days.toKotlinDuration()) + assertEquals((-1).kotlinDays, (-1L).days.toKotlinDuration()) + assertEquals(Long.MIN_VALUE.kotlinDays, Long.MIN_VALUE.days.toKotlinDuration()) } - @ExperimentalTime @Test fun `conversion from Kotlin Duration`() { - assertEquals(0.days, KotlinDuration.days(0).toIslandDays()) - assertEquals(1.days, KotlinDuration.days(1).toIslandDays()) - assertEquals((-1).days, KotlinDuration.days(-1L).toIslandDays()) - assertEquals(Long.MIN_VALUE.days, KotlinDuration.days(Long.MIN_VALUE).toIslandDays()) + assertEquals(0.days, 0.kotlinDays.toIslandDays()) + assertEquals(1.days, 1.kotlinDays.toIslandDays()) + assertEquals((-1).days, (-1).kotlinDays.toIslandDays()) + assertEquals(Long.MIN_VALUE.days, Long.MIN_VALUE.kotlinDays.toIslandDays()) } } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/DurationTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/DurationTest.kt index a136dd88a..f0d54a343 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/DurationTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/DurationTest.kt @@ -3,8 +3,8 @@ package io.islandtime.measures import io.islandtime.measures.TimeUnit.* import io.islandtime.parser.DateTimeParseException import kotlin.test.* -import kotlin.time.ExperimentalTime -import kotlin.time.Duration as KotlinDuration +import kotlin.time.Duration.Companion.seconds as kotlinSeconds +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds class DurationTest { @Test @@ -15,21 +15,21 @@ class DurationTest { } @Test - fun `durationOf() creates durations with positive hours`() { + fun `durationOf creates durations with positive hours`() { val duration = durationOf(1.hours) assertEquals(3600L.seconds, duration.seconds) assertEquals(0.nanoseconds, duration.nanosecondAdjustment) } @Test - fun `durationOf() creates durations with negative hours`() { + fun `durationOf creates durations with negative hours`() { val duration = durationOf((-1).hours) assertEquals((-3600L).seconds, duration.seconds) assertEquals(0.nanoseconds, duration.nanosecondAdjustment) } @Test - fun `durationOf() creates durations with positive nanoseconds`() { + fun `durationOf creates durations with positive nanoseconds`() { val duration1 = durationOf(5.nanoseconds) assertEquals(0L.seconds, duration1.seconds) assertEquals(5.nanoseconds, duration1.nanosecondAdjustment) @@ -40,7 +40,7 @@ class DurationTest { } @Test - fun `durationOf() creates durations with negative nanoseconds`() { + fun `durationOf creates durations with negative nanoseconds`() { val duration1 = durationOf((-5).nanoseconds) assertEquals(0L.seconds, duration1.seconds) assertEquals((-5).nanoseconds, duration1.nanosecondAdjustment) @@ -51,7 +51,7 @@ class DurationTest { } @Test - fun `durationOf() creates durations from seconds and nanoseconds components`() { + fun `durationOf creates durations from seconds and nanoseconds components`() { val duration1 = durationOf(1.seconds, (-5).nanoseconds) assertEquals(0L.seconds, duration1.seconds) assertEquals(999_999_995.nanoseconds, duration1.nanosecondAdjustment) @@ -66,29 +66,29 @@ class DurationTest { } @Test - fun `isZero() returns true for duration of no length`() { + fun `isZero returns true for duration of no length`() { assertTrue { Duration.ZERO.isZero() } } @Test - fun `isZero() returns false for non-zero durations`() { + fun `isZero returns false for non-zero durations`() { assertFalse { durationOf(1.seconds).isZero() } assertFalse { durationOf((-1).seconds).isZero() } assertFalse { durationOf(1.nanoseconds).isZero() } } @Test - fun `isNegative() returns true if seconds is negative`() { + fun `isNegative returns true if seconds is negative`() { assertTrue { durationOf((-1).seconds).isNegative() } } @Test - fun `isNegative() returns true if nanosecondAdjustment is negative`() { + fun `isNegative returns true if nanosecondAdjustment is negative`() { assertTrue { durationOf((-1).nanoseconds).isNegative() } } @Test - fun `isNegative() returns false if greater or equal to zero`() { + fun `isNegative returns false if greater or equal to zero`() { assertFalse { Duration.ZERO.isNegative() } assertFalse { 1.seconds.asDuration().isNegative() } assertFalse { 1.nanoseconds.asDuration().isNegative() } @@ -311,7 +311,7 @@ class DurationTest { } @Test - fun `toComponents() executes function with expected arguments`() { + fun `toComponents executes function with expected arguments`() { durationOf(5.hours + 30.minutes + 30.seconds + 500.milliseconds) .toComponents { hours, minutes, seconds, nanoseconds -> assertEquals(5L.hours, hours) @@ -331,7 +331,7 @@ class DurationTest { } @Test - fun `truncatedTo(DAYS) truncates the precision to 24-hour days`() { + fun `truncatedTo_DAYS truncates the precision to 24-hour days`() { assertEquals( 1.days.asDuration(), durationOf(1.days + 1.hours + 1.nanoseconds).truncatedTo(DAYS) @@ -351,7 +351,7 @@ class DurationTest { } @Test - fun `truncatedTo(HOURS) truncates the precision to hours`() { + fun `truncatedTo_HOURS truncates the precision to hours`() { assertEquals( 1.hours.asDuration(), durationOf(1.hours + 1.minutes + 1.nanoseconds).truncatedTo(HOURS) @@ -371,7 +371,7 @@ class DurationTest { } @Test - fun `truncatedTo(MINUTES) truncates the precision to minutes`() { + fun `truncatedTo_MINUTES truncates the precision to minutes`() { assertEquals( 1.minutes.asDuration(), durationOf(1.minutes + 1.seconds + 1.nanoseconds).truncatedTo(MINUTES) @@ -391,7 +391,7 @@ class DurationTest { } @Test - fun `truncatedTo(SECONDS) truncates the precision to seconds`() { + fun `truncatedTo_SECONDS truncates the precision to seconds`() { assertEquals( 1.seconds.asDuration(), durationOf(1.seconds + 1.nanoseconds).truncatedTo(SECONDS) @@ -411,7 +411,7 @@ class DurationTest { } @Test - fun `truncatedTo(MILLISECONDS) truncates the precision to milliseconds`() { + fun `truncatedTo_MILLISECONDS truncates the precision to milliseconds`() { assertEquals( 1.milliseconds.asDuration(), durationOf(1.milliseconds + 1.nanoseconds).truncatedTo(MILLISECONDS) @@ -431,7 +431,7 @@ class DurationTest { } @Test - fun `truncatedTo(MICROSECONDS) truncates the precision to microseconds`() { + fun `truncatedTo_MICROSECONDS truncates the precision to microseconds`() { assertEquals( 1.microseconds.asDuration(), durationOf(1.microseconds + 1.nanoseconds).truncatedTo(MICROSECONDS) @@ -457,18 +457,18 @@ class DurationTest { } @Test - fun `abs() returns the absolute value of a duration`() { + fun `abs returns the absolute value of a duration`() { assertEquals(durationOf(30.seconds), abs(30.seconds.asDuration())) assertEquals(durationOf(30.seconds), abs((-30).seconds.asDuration())) } @Test - fun `toString() converts zero durations to 'PT0S'`() { + fun `toString converts zero durations to 'PT0S'`() { assertEquals("PT0S", Duration.ZERO.toString()) } @Test - fun `toString() converts positive durations to ISO-8601 duration representation`() { + fun `toString converts positive durations to ISO-8601 duration representation`() { assertEquals( "PT25H30M30.5S", durationOf(1.days + 1.hours + 30.minutes + 30.seconds + 500.milliseconds).toString() @@ -481,7 +481,7 @@ class DurationTest { } @Test - fun `toString() converts negative durations to ISO-8601 duration representation`() { + fun `toString converts negative durations to ISO-8601 duration representation`() { assertEquals( "PT-25H-30M-30.5S", durationOf((-1).days - 1.hours - 30.minutes - 30.seconds - 500.milliseconds).toString() @@ -494,12 +494,12 @@ class DurationTest { } @Test - fun `String_toDuration() throws an exception when string is empty`() { + fun `String_toDuration throws an exception when string is empty`() { assertFailsWith { "".toDuration() } } @Test - fun `String_toDuration() throws an exception when string is invalid`() { + fun `String_toDuration throws an exception when string is invalid`() { assertFailsWith { "P4Y".toDuration() } assertFailsWith { "P4M".toDuration() } assertFailsWith { "PT4H ".toDuration() } @@ -509,13 +509,13 @@ class DurationTest { } @Test - fun `String_toDuration() parses durations of zero`() { + fun `String_toDuration parses durations of zero`() { assertEquals(Duration.ZERO, "P0D".toDuration()) assertEquals(Duration.ZERO, "PT0S".toDuration()) } @Test - fun `String_toDuration() converts ISO-8601 period strings to a Duration`() { + fun `String_toDuration converts ISO-8601 period strings to a Duration`() { assertEquals( durationOf(1.seconds), "PT1S".toDuration() @@ -542,26 +542,24 @@ class DurationTest { ) } - @ExperimentalTime @Test fun `conversion to Kotlin Duration`() { assertEquals( - KotlinDuration.seconds(1.000_000_100), + 1.kotlinSeconds + 100.kotlinNanoseconds, durationOf(1.seconds, 100.nanoseconds).toKotlinDuration() ) assertEquals( - KotlinDuration.seconds(-1.000_000_100), + (-1).kotlinSeconds + (-100).kotlinNanoseconds, durationOf((-1).seconds, (-100).nanoseconds).toKotlinDuration() ) } - @ExperimentalTime @Test fun `conversion from Kotlin Duration`() { assertEquals( durationOf(5.seconds, 1.nanoseconds), - (KotlinDuration.seconds(5) + KotlinDuration.nanoseconds(1)).toIslandDuration() + (5.kotlinSeconds + 1.kotlinNanoseconds).toIslandDuration() ) } } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/HoursTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/HoursTest.kt index 0265fc9b7..27663b653 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/HoursTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/HoursTest.kt @@ -5,7 +5,7 @@ import kotlin.test.assertEquals class HoursTest { @Test - fun `toComponents() breaks the hours up into days and hours`() { + fun `toComponents breaks the hours up into days and hours`() { 36.hours.toComponents { days, hours -> assertEquals(1.days, days) assertEquals(12.hours, hours) @@ -13,7 +13,7 @@ class HoursTest { } @Test - fun `toComponentValues() breaks the hours up into days and hours`() { + fun `toComponentValues breaks the hours up into days and hours`() { 36.hours.toComponentValues { days, hours -> assertEquals(1L, days) assertEquals(12, hours) @@ -21,12 +21,12 @@ class HoursTest { } @Test - fun `toString() converts zero hours to 'PT0H'`() { + fun `toString converts zero hours to 'PT0H'`() { assertEquals("PT0H", 0.hours.toString()) } @Test - fun `toString() converts to ISO-8601 period representation`() { + fun `toString converts to ISO-8601 period representation`() { assertEquals("PT1H", 1.hours.toString()) assertEquals("-PT1H", (-1).hours.toString()) } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/MinutesTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/MinutesTest.kt index 5e1d19e36..d8438500f 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/MinutesTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/MinutesTest.kt @@ -17,7 +17,7 @@ class MinutesTest { } @Test - fun `toComponents() breaks the minutes up into days, hours, and minutes`() { + fun `toComponents breaks the minutes up into days + hours + minutes`() { (1.days + 1.hours + 1.minutes).toComponents { days, hours, minutes -> assertEquals(1.days, days) assertEquals(1.hours, hours) @@ -26,7 +26,7 @@ class MinutesTest { } @Test - fun `toComponentValues() breaks the minutes up into days, hours, and minutes`() { + fun `toComponentValues breaks the minutes up into days + hours + minutes`() { (1.days + 1.hours + 1.minutes).toComponentValues { days, hours, minutes -> assertEquals(1L, days) assertEquals(1, hours) @@ -35,7 +35,7 @@ class MinutesTest { } @Test - fun `toComponents() breaks the minutes up into hours, and minutes`() { + fun `toComponents breaks the minutes up into hours + minutes`() { (1.days + 1.hours + 1.minutes).toComponents { hours, minutes -> assertEquals(25.hours, hours) assertEquals(1.minutes, minutes) @@ -43,7 +43,7 @@ class MinutesTest { } @Test - fun `toComponentValues() breaks the minutes up into hours, and minutes`() { + fun `toComponentValues breaks the minutes up into hours + minutes`() { (1.days + 1.hours + 1.minutes).toComponentValues { hours, minutes -> assertEquals(25L, hours) assertEquals(1, minutes) @@ -51,12 +51,12 @@ class MinutesTest { } @Test - fun `Minutes_toString() converts zero minutes to 'PT0M'`() { + fun `Minutes_toString converts zero minutes to 'PT0M'`() { assertEquals("PT0M", 0.minutes.toString()) } @Test - fun `Minutes_toString() converts to ISO-8601 period representation`() { + fun `Minutes_toString converts to ISO-8601 period representation`() { assertEquals("PT1M", 1.minutes.toString()) assertEquals("-PT1M", (-1).minutes.toString()) } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/NanosecondsTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/NanosecondsTest.kt index 73bd255a7..87215be10 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/NanosecondsTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/NanosecondsTest.kt @@ -4,8 +4,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue -import kotlin.time.ExperimentalTime -import kotlin.time.Duration as KotlinDuration +import kotlin.time.Duration.Companion.nanoseconds as kotlinNanoseconds class NanosecondsTest { @Test @@ -108,28 +107,28 @@ class NanosecondsTest { } @Test - fun `toLong() converts to Long`() { + fun `toLong converts to Long`() { listOf(0, -1, 1, Long.MIN_VALUE, Long.MAX_VALUE).forEach { assertEquals(it, it.nanoseconds.toLong()) } } @Test - fun `toInt() throws an exception if overflow occurs during conversion`() { + fun `toInt throws an exception if overflow occurs during conversion`() { listOf(Int.MAX_VALUE + 1L, Int.MIN_VALUE - 1L).forEach { assertFailsWith { it.nanoseconds.toInt() } } } @Test - fun `toInt() converts to Int`() { + fun `toInt converts to Int`() { listOf(0, -1, 1, Int.MAX_VALUE, Int.MIN_VALUE).forEach { assertEquals(it, it.nanoseconds.toInt()) } } @Test - fun `toString() returns an ISO duration string`() { + fun `toString returns an ISO duration string`() { listOf( 0 to "PT0S", 1 to "PT0.000000001S", @@ -154,7 +153,7 @@ class NanosecondsTest { } @Test - fun `toComponents() and toComponentValues() with days, hours, minutes, seconds, milliseconds, and microseconds`() { + fun `toComponents and toComponentValues with days + hours + minutes + seconds + milliseconds + microseconds`() { listOf( 0 to listOf(0, 0, 0, 0, 0, 0, 0), 1 to listOf(0, 0, 0, 0, 0, 0, 1), @@ -185,7 +184,7 @@ class NanosecondsTest { } @Test - fun `toComponents() and toComponentValues() with microseconds`() { + fun `toComponents and toComponentValues with microseconds`() { listOf( 0 to listOf(0, 0), 1 to listOf(0, 1), @@ -205,25 +204,23 @@ class NanosecondsTest { } } - @ExperimentalTime @Test fun `conversion to Kotlin Duration`() { - assertEquals(KotlinDuration.nanoseconds(0), 0.nanoseconds.toKotlinDuration()) - assertEquals(KotlinDuration.nanoseconds(1), 1.nanoseconds.toKotlinDuration()) - assertEquals(KotlinDuration.nanoseconds(-1), (-1).nanoseconds.toKotlinDuration()) - assertEquals(KotlinDuration.nanoseconds(Long.MIN_VALUE), Long.MIN_VALUE.nanoseconds.toKotlinDuration()) + assertEquals(0.kotlinNanoseconds, 0.nanoseconds.toKotlinDuration()) + assertEquals(1.kotlinNanoseconds, 1.nanoseconds.toKotlinDuration()) + assertEquals((-1).kotlinNanoseconds, (-1).nanoseconds.toKotlinDuration()) + assertEquals(Long.MIN_VALUE.kotlinNanoseconds, Long.MIN_VALUE.nanoseconds.toKotlinDuration()) } - @ExperimentalTime @Test fun `conversion from Kotlin Duration`() { - assertEquals(0.nanoseconds, KotlinDuration.nanoseconds(0).toIslandNanoseconds()) - assertEquals(1.nanoseconds, KotlinDuration.nanoseconds(1).toIslandNanoseconds()) - assertEquals((-1).nanoseconds, KotlinDuration.nanoseconds(-1).toIslandNanoseconds()) + assertEquals(0.nanoseconds, 0.kotlinNanoseconds.toIslandNanoseconds()) + assertEquals(1.nanoseconds, 1.kotlinNanoseconds.toIslandNanoseconds()) + assertEquals((-1).nanoseconds, (-1).kotlinNanoseconds.toIslandNanoseconds()) assertEquals( Long.MIN_VALUE.nanoseconds.inWholeMilliseconds.inNanoseconds, - KotlinDuration.nanoseconds(Long.MIN_VALUE).toIslandNanoseconds() + Long.MIN_VALUE.kotlinNanoseconds.toIslandNanoseconds() ) } } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/PeriodTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/PeriodTest.kt index d8ae73b91..d08d54920 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/PeriodTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/PeriodTest.kt @@ -14,7 +14,7 @@ class PeriodTest { } @Test - fun `periodOf() constructs periods of years`() { + fun `periodOf constructs periods of years`() { val period = periodOf(10.years) assertEquals(10.years, period.years) @@ -23,7 +23,7 @@ class PeriodTest { } @Test - fun `periodOf() constructs periods of months`() { + fun `periodOf constructs periods of months`() { val period = periodOf(15.months) assertEquals(0.years, period.years) @@ -32,7 +32,7 @@ class PeriodTest { } @Test - fun `periodOf() constructs periods of weeks with equivalent days`() { + fun `periodOf constructs periods of weeks with equivalent days`() { val period = periodOf((-1).weeks) assertEquals(0.years, period.years) @@ -41,7 +41,7 @@ class PeriodTest { } @Test - fun `periodOf() constructs periods of days`() { + fun `periodOf constructs periods of days`() { val period = periodOf(100.days) assertEquals(0.years, period.years) @@ -50,7 +50,7 @@ class PeriodTest { } @Test - fun `asPeriod() converts years to a period with similar years`() { + fun `asPeriod converts years to a period with similar years`() { val period = 3.years.asPeriod() assertEquals(3.years, period.years) @@ -59,7 +59,7 @@ class PeriodTest { } @Test - fun `asPeriod() converts months to a period with similar months`() { + fun `asPeriod converts months to a period with similar months`() { val period = (1.years + 3.months).asPeriod() assertEquals(0.years, period.years) @@ -68,7 +68,7 @@ class PeriodTest { } @Test - fun `asPeriod() converts weeks to a period with similar days`() { + fun `asPeriod converts weeks to a period with similar days`() { val period1 = 1.weeks.asPeriod() assertEquals(0.years, period1.years) assertEquals(0.months, period1.months) @@ -81,7 +81,7 @@ class PeriodTest { } @Test - fun `asPeriod() converts days to a period with similar days`() { + fun `asPeriod converts days to a period with similar days`() { val period = 10.days.asPeriod() assertEquals(0.years, period.years) @@ -116,12 +116,12 @@ class PeriodTest { } @Test - fun `toString() returns 'P0D' when the period is zero`() { + fun `toString returns 'P0D' when the period is zero`() { assertEquals("P0D", Period.ZERO.toString()) } @Test - fun `toString() returns a valid ISO8601 period representation of non-zero periods`() { + fun `toString returns a valid ISO8601 period representation of non-zero periods`() { listOf( periodOf(1.years) to "P1Y", periodOf((-1).years) to "P-1Y", @@ -143,17 +143,17 @@ class PeriodTest { } @Test - fun `String_toPeriod() throws an exception when string is empty`() { + fun `String_toPeriod throws an exception when string is empty`() { assertFailsWith { "".toPeriod() } } @Test - fun `String_toPeriod() parses zero ISO-8601 period strings`() { + fun `String_toPeriod parses zero ISO-8601 period strings`() { assertEquals(Period.ZERO, "P0D".toPeriod()) } @Test - fun `String_toPeriod() parses valid ISO-8601 period strings`() { + fun `String_toPeriod parses valid ISO-8601 period strings`() { listOf( "P1Y13M6D" to periodOf(1.years, 13.months, 6.days), "P-1M10D" to periodOf((-1).months, 10.days), @@ -166,7 +166,7 @@ class PeriodTest { } @Test - fun `String_toPeriod() throws an exception when the string contains duration components`() { + fun `String_toPeriod throws an exception when the string contains duration components`() { listOf( "PT0S", "P1DT1H", @@ -188,24 +188,24 @@ class PeriodTest { } @Test - fun `isZero() returns true for zeroed-out periods`() { + fun `isZero returns true for zeroed-out periods`() { assertTrue { Period.ZERO.isZero() } } @Test - fun `isZero() returns false for non-zero periods`() { + fun `isZero returns false for non-zero periods`() { assertFalse { periodOf(1.days).isZero() } } @Test - fun `isNegative() returns true if any component is less than zero`() { + fun `isNegative returns true if any component is less than zero`() { assertTrue { periodOf((-1).years, 1.months, 1.days).isNegative() } assertTrue { periodOf(1.years, (-1).months, 1.days).isNegative() } assertTrue { periodOf(1.years, 1.months, (-1).days).isNegative() } } @Test - fun `isNegative() returns false if all components are zero or more`() { + fun `isNegative returns false if all components are zero or more`() { listOf( periodOf(1.years, 0.months, 0.days), periodOf(0.years, 1.months, 0.days), @@ -217,22 +217,22 @@ class PeriodTest { } @Test - fun `copy() replaces years value`() { + fun `copy replaces years value`() { assertEquals(periodOf((-1).years, 12.months), periodOf(1.years, 12.months).copy(years = (-1).years)) } @Test - fun `copy() replaces months value`() { + fun `copy replaces months value`() { assertEquals(periodOf(1.years, 12.months), periodOf(1.years, 3.months).copy(months = 12.months)) } @Test - fun `copy() replaces days value`() { + fun `copy replaces days value`() { assertEquals(Period.ZERO, periodOf(10.days).copy(days = 0.days)) } @Test - fun `normalized() converts months into whole years where possible`() { + fun `normalized converts months into whole years where possible`() { assertEquals( periodOf(1.years, 11.months, 20.days), periodOf(1.years, 11.months, 20.days).normalized() @@ -250,7 +250,7 @@ class PeriodTest { } @Test - fun `normalized() throws an exception when overflow occurs`() { + fun `normalized throws an exception when overflow occurs`() { assertFailsWith { periodOf(Long.MAX_VALUE.years, Long.MAX_VALUE.months).normalized() } assertFailsWith { periodOf(Long.MIN_VALUE.years, Long.MIN_VALUE.months).normalized() } } diff --git a/core/src/commonTest/kotlin/io/islandtime/measures/YearsTest.kt b/core/src/commonTest/kotlin/io/islandtime/measures/YearsTest.kt index 0ce4b913f..03e5a0f7f 100644 --- a/core/src/commonTest/kotlin/io/islandtime/measures/YearsTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/measures/YearsTest.kt @@ -1,6 +1,5 @@ package io.islandtime.measures -import kotlin.math.absoluteValue import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -13,7 +12,7 @@ class YearsTest { assertTrue { 0.years == 0.years } assertTrue { 5.years > (-1).years } } - + @Test fun `absoluteValue returns the same value for 0 or positive values`() { listOf(0, 1, Long.MAX_VALUE).forEach { @@ -66,7 +65,7 @@ class YearsTest { @Test fun `dividing by -1 throws an exception when value is MIN_VALUE`() { - assertFailsWith { Long.MIN_VALUE.years / -1 } + assertFailsWith { Long.MIN_VALUE.years / -1 } } @Test @@ -142,28 +141,28 @@ class YearsTest { } @Test - fun `toLong() converts to Long`() { + fun `toLong converts to Long`() { listOf(0, -1, 1, Long.MIN_VALUE, Long.MAX_VALUE).forEach { assertEquals(it, it.years.toLong()) } } @Test - fun `toInt() throws an exception if overflow occurs during conversion`() { + fun `toInt throws an exception if overflow occurs during conversion`() { listOf(Int.MAX_VALUE + 1L, Int.MIN_VALUE - 1L).forEach { assertFailsWith { it.years.toInt() } } } @Test - fun `toInt() converts to Int`() { + fun `toInt converts to Int`() { listOf(0, -1, 1, Int.MAX_VALUE, Int.MIN_VALUE).forEach { assertEquals(it, it.years.toInt()) } } @Test - fun `toString() returns an ISO duration string`() { + fun `toString returns an ISO duration string`() { listOf( 0L to "P0Y", 1L to "P1Y", @@ -176,7 +175,7 @@ class YearsTest { } @Test - fun `toComponents() and toComponentValues() with centuries and decades`() { + fun `toComponents and toComponentValues with centuries and decades`() { listOf( 0 to listOf(0, 0, 0), 1 to listOf(0, 0, 1), @@ -201,7 +200,7 @@ class YearsTest { } @Test - fun `toComponents() and toComponentValues() with decades`() { + fun `toComponents and toComponentValues with decades`() { listOf( 0 to listOf(0, 0), 1 to listOf(0, 1), diff --git a/core/src/commonTest/kotlin/io/islandtime/operators/StartEndTest.kt b/core/src/commonTest/kotlin/io/islandtime/operators/StartEndTest.kt index cc8946b11..d0fddc289 100644 --- a/core/src/commonTest/kotlin/io/islandtime/operators/StartEndTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/operators/StartEndTest.kt @@ -97,7 +97,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `Date_startOfWeek() returns the date at the start of the week in locale`() { + fun `Date_startOfWeek returns the date at the start of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -122,7 +122,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_startOfWeek() returns the date-time at the start of the week in locale`() { + fun `DateTime_startOfWeek returns the date-time at the start of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -152,7 +152,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_startOfWeek() returns the date-time at the start of the week in locale`() { + fun `OffsetDateTime_startOfWeek returns the date-time at the start of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -186,7 +186,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_startOfWeek() returns the date-time at the start of the week in locale`() { + fun `ZonedDateTime_startOfWeek returns the date-time at the start of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -293,7 +293,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `Date_endOfWeek() returns the date at the end of the week in locale`() { + fun `Date_endOfWeek returns the date at the end of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -318,7 +318,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `DateTime_endOfWeek() returns the date-time at the end of the week in locale`() { + fun `DateTime_endOfWeek returns the date-time at the end of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -348,7 +348,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `OffsetDateTime_endOfWeek() returns the date-time at the end of the week in locale`() { + fun `OffsetDateTime_endOfWeek returns the date-time at the end of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( @@ -382,7 +382,7 @@ class StartEndTest : AbstractIslandTimeTest() { } @Test - fun `ZonedDateTime_endOfWeek() returns the date-time at the end of the week in locale`() { + fun `ZonedDateTime_endOfWeek returns the date-time at the end of the week in locale`() { val sundayFirstLocale = "en-US".toLocale() assertEquals( diff --git a/core/src/commonTest/kotlin/io/islandtime/operators/TruncationTest.kt b/core/src/commonTest/kotlin/io/islandtime/operators/TruncationTest.kt index b23bc95e2..0c9108a9b 100644 --- a/core/src/commonTest/kotlin/io/islandtime/operators/TruncationTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/operators/TruncationTest.kt @@ -9,7 +9,7 @@ import kotlin.test.assertEquals class TruncationTest : AbstractIslandTimeTest() { @Test - fun `truncatedTo(DAYS) returns midnight`() { + fun `truncatedTo_DAYS returns midnight`() { assertEquals( Time.MIDNIGHT, Time(0, 0, 0, 1).truncatedTo(DAYS) @@ -17,7 +17,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(HOURS) removes components smaller than hours`() { + fun `truncatedTo_HOURS removes components smaller than hours`() { assertEquals( Time(1, 0), Time(1, 2, 3, 4).truncatedTo(HOURS) @@ -25,7 +25,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(MINUTES) removes components smaller than minutes`() { + fun `truncatedTo_MINUTES removes components smaller than minutes`() { assertEquals( Time(1, 2), Time(1, 2, 3, 4).truncatedTo(MINUTES) @@ -33,7 +33,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(SECONDS) removes components smaller than seconds`() { + fun `truncatedTo_SECONDS removes components smaller than seconds`() { assertEquals( Time(1, 2, 3), Time(1, 2, 3, 4).truncatedTo(SECONDS) @@ -41,7 +41,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(MILLISECONDS) removes components smaller than milliseconds`() { + fun `truncatedTo_MILLISECONDS removes components smaller than milliseconds`() { assertEquals( Time(1, 2, 3, 444_000_000), Time(1, 2, 3, 444_555_666).truncatedTo(MILLISECONDS) @@ -49,7 +49,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(MICROSECONDS) removes components smaller than microseconds`() { + fun `truncatedTo_MICROSECONDS removes components smaller than microseconds`() { assertEquals( Time(1, 2, 3, 444_555_000), Time(1, 2, 3, 444_555_666).truncatedTo(MICROSECONDS) @@ -57,7 +57,7 @@ class TruncationTest : AbstractIslandTimeTest() { } @Test - fun `truncatedTo(NANOSECONDS) does nothing`() { + fun `truncatedTo_NANOSECONDS does nothing`() { assertEquals( Time(1, 2, 3, 444_555_666), Time(1, 2, 3, 444_555_666).truncatedTo(NANOSECONDS) diff --git a/core/src/commonTest/kotlin/io/islandtime/parser/GroupedDateTimeParserTest.kt b/core/src/commonTest/kotlin/io/islandtime/parser/GroupedDateTimeParserTest.kt index 78d6fdb8d..6fac393a6 100644 --- a/core/src/commonTest/kotlin/io/islandtime/parser/GroupedDateTimeParserTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/parser/GroupedDateTimeParserTest.kt @@ -26,7 +26,7 @@ class GroupedDateTimeParserTest { } @Test - fun `number of results matches the number of groups defined, even when empty`() { + fun `number of results matches the number of groups defined even when empty`() { val result1 = groupedDateTimeParser { group {} }.parse("") assertEquals(1, result1.size) assertTrue { result1[0].isEmpty() } @@ -41,7 +41,7 @@ class GroupedDateTimeParserTest { } @Test - fun `number of results matches the number of groups defined, ignoring literals`() { + fun `number of results matches the number of groups defined ignoring literals`() { val result1 = groupedDateTimeParser { +' ' group {} @@ -143,7 +143,7 @@ class GroupedDateTimeParserTest { } @Test - fun `anyOf() enables reuse of existing grouped parsers`() { + fun `anyOf enables reuse of existing grouped parsers`() { val existingParser = groupedDateTimeParser { group { wholeNumber(2) { associateWith(DateTimeField.MONTH_OF_YEAR) } @@ -186,7 +186,7 @@ class GroupedDateTimeParserTest { } @Test - fun `anyOf() uses the the results of the first custom grouped parser to succeed`() { + fun `anyOf uses the the results of the first custom grouped parser to succeed`() { val parser = groupedDateTimeParser { anyOf({ group { diff --git a/core/src/commonTest/kotlin/io/islandtime/parser/internal/ParsersTest.kt b/core/src/commonTest/kotlin/io/islandtime/parser/internal/ParsersTest.kt index 8a72409a5..f26c7810b 100644 --- a/core/src/commonTest/kotlin/io/islandtime/parser/internal/ParsersTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/parser/internal/ParsersTest.kt @@ -12,7 +12,7 @@ class ParsersTest { private val hi_IN_u_nu_native = "hi-IN-u-nu-native".toLocale() @Test - fun `Char_toDigit() converts a character to a digit according to NumberStyle`() { + fun `Char_toDigit converts a character to a digit according to NumberStyle`() { assertEquals(0, '0'.toDigit(en_US.numberStyle)) assertEquals(9, '9'.toDigit(en_US.numberStyle)) @@ -24,7 +24,7 @@ class ParsersTest { } @Test - fun `Char_toDigit() returns -1 when the character isn't considered a digit`() { + fun `Char_toDigit returns -1 when the character isn't considered a digit`() { assertEquals(-1, '/'.toDigit(en_US.numberStyle)) assertEquals(-1, ':'.toDigit(en_US.numberStyle)) } diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/DateDayProgressionTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/DateDayProgressionTest.kt index 33baef9ea..e53b3c296 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/DateDayProgressionTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/DateDayProgressionTest.kt @@ -59,7 +59,7 @@ class DateDayProgressionTest : AbstractIslandTimeTest() { } @Test - fun `reversed() creates a reserved progression`() { + fun `reversed creates a reserved progression`() { val startDate = Date(2019, Month.JANUARY, 21) val endDate = Date(2019, Month.JANUARY, 28) val range = (startDate..endDate).reversed() diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/DateMonthProgressionTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/DateMonthProgressionTest.kt index 36f96cab0..ed81b6af7 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/DateMonthProgressionTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/DateMonthProgressionTest.kt @@ -112,7 +112,7 @@ class DateMonthProgressionTest : AbstractIslandTimeTest() { } @Test - fun `reversed() creates a reserved progression`() { + fun `reversed creates a reserved progression`() { val start = Date(2018, Month.JANUARY, 31) val end = Date(2018, Month.APRIL, 30) val progression = (start..end step 1.months).reversed() diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/DateRangeTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/DateRangeTest.kt index 6d66c7b62..f87409065 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/DateRangeTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/DateRangeTest.kt @@ -11,7 +11,7 @@ import kotlin.test.* class DateRangeTest : AbstractIslandTimeTest() { @Test - fun `contains() returns true for dates within range`() { + fun `contains returns true for dates within range`() { val startDate = Date(2018, Month.DECEMBER, 25) val endDate = Date(2019, Month.JANUARY, 12) @@ -21,7 +21,7 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for out of range dates`() { + fun `contains returns false for out of range dates`() { val startDate = Date(2018, Month.DECEMBER, 25) val endDate = Date(2019, Month.JANUARY, 12) @@ -36,7 +36,7 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for null dates`() { + fun `contains returns false for null dates`() { val startDate = Date(2018, Month.DECEMBER, 25) val endDate = Date(2019, Month.JANUARY, 12) @@ -44,12 +44,12 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `isEmpty() returns true when the start is greater than the end`() { + fun `isEmpty returns true when the start is greater than the end`() { assertTrue { (Date(2018, 45)..Date(2018, 44)).isEmpty() } } @Test - fun `isEmpty() returns true when the end is negative infinity or start is positive infinity`() { + fun `isEmpty returns true when the end is negative infinity or start is positive infinity`() { listOf( Date.MIN..Date.MIN, Date.MAX..Date.MAX @@ -79,7 +79,7 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 time interval representation`() { + fun `toString returns an ISO-8601 time interval representation`() { assertEquals( "1969-12-03/1970-02-03", (Date(1969, 12, 3)..Date(1970, 2, 3)).toString() @@ -112,12 +112,12 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateRange() returns an empty range when the string is empty`() { + fun `String_toDateRange returns an empty range when the string is empty`() { assertEquals(DateRange.EMPTY, "".toDateRange()) } @Test - fun `String_toDateRange() parses ISO-8601 time interval strings with dates in extended format`() { + fun `String_toDateRange parses ISO-8601 time interval strings with dates in extended format`() { assertEquals(DateRange.UNBOUNDED, "../..".toDateRange()) assertEquals( @@ -178,20 +178,20 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `random() returns a date within range`() { + fun `random returns a date within range`() { val range = Date(2018, Month.FEBRUARY, 20)..Date(2018, Month.MARCH, 25) val randomDate = range.random() assertTrue { randomDate in range } } @Test - fun `random() throws an exception when the range is empty`() { + fun `random throws an exception when the range is empty`() { assertFailsWith { DateRange.EMPTY.random() } assertFailsWith { DateRange.EMPTY.random(Random) } } @Test - fun `random() throws an exception when the range is not bounded`() { + fun `random throws an exception when the range is not bounded`() { assertFailsWith { DateRange.UNBOUNDED.random() } assertFailsWith { DateRange.UNBOUNDED.random(Random) } @@ -205,13 +205,13 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns null when the range is empty`() { + fun `randomOrNull returns null when the range is empty`() { assertNull(DateRange.EMPTY.randomOrNull()) assertNull(DateRange.EMPTY.randomOrNull(Random)) } @Test - fun `randomOrNull() returns null when the range is not bounded`() { + fun `randomOrNull returns null when the range is not bounded`() { assertNull(DateRange.UNBOUNDED.randomOrNull()) assertNull(DateRange.UNBOUNDED.randomOrNull(Random)) assertNull(DateRange(start = Date(2020, Month.APRIL, 1)).randomOrNull()) @@ -219,7 +219,7 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns a date within range`() { + fun `randomOrNull returns a date within range`() { val range = Date(2018, Month.FEBRUARY, 20)..Date(2018, Month.FEBRUARY, 20) assertTrue { range.randomOrNull()!! in range } assertTrue { range.randomOrNull(Random)!! in range } @@ -314,13 +314,13 @@ class DateRangeTest : AbstractIslandTimeTest() { } @Test - fun `toPeriod() returns a period of 1 day when the start and end date are equal`() { + fun `toPeriod returns a period of 1 day when the start and end date are equal`() { val date = Date(2019, Month.JUNE, 1) assertEquals(periodOf(1.days), (date..date).toPeriod()) } @Test - fun `toPeriod() returns the expected period for non-empty ranges`() { + fun `toPeriod returns the expected period for non-empty ranges`() { val start = Date(2018, Month.FEBRUARY, 20) val end = Date(2019, Month.MARCH, 20) assertEquals(periodOf(1.years, 1.months, 1.days), (start..end).toPeriod()) diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/DateTimeIntervalTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/DateTimeIntervalTest.kt index e599ca213..a52e5f684 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/DateTimeIntervalTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/DateTimeIntervalTest.kt @@ -62,7 +62,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within bounded range`() { + fun `contains returns true for dates within bounded range`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT val end = Date(2019, Month.MARCH, 12) at MIDNIGHT @@ -72,7 +72,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded end`() { + fun `contains returns true for dates within range with unbounded end`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT val end = DateTime.MAX @@ -81,7 +81,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded start`() { + fun `contains returns true for dates within range with unbounded start`() { val start = DateTime.MIN val end = Date(2019, Month.MARCH, 10) at MIDNIGHT @@ -90,7 +90,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for out of range dates`() { + fun `contains returns false for out of range dates`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT val end = Date(2019, Month.MARCH, 12) at MIDNIGHT @@ -111,12 +111,12 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() throws an exception when the interval is empty`() { + fun `random throws an exception when the interval is empty`() { assertFailsWith { DateTimeInterval.EMPTY.random() } } @Test - fun `random() throws an exception when the interval is not bounded`() { + fun `random throws an exception when the interval is not bounded`() { val dateTime = DateTime(2019, Month.MARCH, 1, 13, 0) assertFailsWith { DateTimeInterval.UNBOUNDED.random() } assertFailsWith { DateTimeInterval(start = dateTime).random() } @@ -124,13 +124,13 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns null when the interval is empty`() { + fun `randomOrNull returns null when the interval is empty`() { assertNull(DateTimeInterval.EMPTY.randomOrNull()) assertNull(DateTimeInterval.EMPTY.randomOrNull(Random)) } @Test - fun `randomOrNull() returns null when the interval is not bounded`() { + fun `randomOrNull returns null when the interval is not bounded`() { val dateTime = DateTime(2019, Month.MARCH, 1, 13, 0) assertNull(DateTimeInterval.UNBOUNDED.randomOrNull()) assertNull(DateTimeInterval.UNBOUNDED.randomOrNull(Random)) @@ -139,7 +139,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() and randomOrNull() return a date-time within the interval`() { + fun `random and randomOrNull return a date-time within the interval`() { listOf( Date(2019, Month.NOVEMBER, 1) at MIDNIGHT, Date(2019, Month.NOVEMBER, 1) at Time(0, 0, 0, 1), @@ -173,12 +173,12 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `toDuration() returns a zeroed out duration when the range is empty`() { + fun `toDuration returns a zeroed out duration when the range is empty`() { assertEquals(Duration.ZERO, DateTimeInterval.EMPTY.toDuration()) } @Test - fun `toDuration() throws an exception when the range is unbounded`() { + fun `toDuration throws an exception when the range is unbounded`() { assertFailsWith { DateTimeInterval(endExclusive = "2018-09-10T09:15".toDateTime()).toDuration() } @@ -193,12 +193,12 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `toPeriod() returns a zeroed out period when the range is empty`() { + fun `toPeriod returns a zeroed out period when the range is empty`() { assertEquals(Period.ZERO, DateTimeInterval.EMPTY.toPeriod()) } @Test - fun `toPeriod() throws an exception when the range is unbounded`() { + fun `toPeriod throws an exception when the range is unbounded`() { assertFailsWith { DateTimeInterval(endExclusive = "2018-09-10T09:15".toDateTime()).toPeriod() } @@ -356,12 +356,12 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { @Test fun `lengthInNanoseconds returns 1 in an inclusive interval where the start and end date-times are the same`() { - val dateTime = Date(2019, Month.MARCH, 10) at Time.MIDNIGHT + val dateTime = Date(2019, Month.MARCH, 10) at MIDNIGHT assertEquals(1L.nanoseconds, (dateTime..dateTime).lengthInNanoseconds) } @Test - fun `toString() returns an ISO-8601 time interval representation`() { + fun `toString returns an ISO-8601 time interval representation`() { assertEquals( "2000-12-31T00:00/2001-01-02T00:00", (DateTime(2000, 12, 31, 0, 0) until @@ -395,18 +395,18 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateTimeInterval() converts an empty string to an empty interval`() { + fun `String_toDateTimeInterval converts an empty string to an empty interval`() { assertEquals(DateTimeInterval.EMPTY, "".toDateTimeInterval()) } @Test - fun `String_toDateTimeInterval() throws an exception when the format is invalid`() { + fun `String_toDateTimeInterval throws an exception when the format is invalid`() { assertFailsWith { "2000-01-01/2000-01-01".toDateTimeInterval() } assertFailsWith { "2000-01-01T00:00/20000101T01".toDateTimeInterval() } } @Test - fun `String_toDateTimeInterval() parses ISO-8601 time interval strings in extended format by default`() { + fun `String_toDateTimeInterval parses ISO-8601 time interval strings in extended format by default`() { assertEquals( DateTime(1969, 12, 31, 0, 0) until DateTime(1970, 1, 2, 0, 0), @@ -428,7 +428,7 @@ class DateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `String_toDateTimeInterval() throws an exception when required properties are missing`() { + fun `String_toDateTimeInterval throws an exception when required properties are missing`() { val customParser = groupedDateTimeParser { group { optional { diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/InstantIntervalTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/InstantIntervalTest.kt index 6c1abe2e2..9847ee1cd 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/InstantIntervalTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/InstantIntervalTest.kt @@ -40,7 +40,7 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within bounded range`() { + fun `contains returns true for dates within bounded range`() { val start = Instant((-2L).days.inSeconds) val end = Instant(2L.days.inSeconds) @@ -51,7 +51,7 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded end`() { + fun `contains returns true for dates within range with unbounded end`() { val start = Instant((-2L).days.inSeconds) val end = Instant.MAX @@ -62,7 +62,7 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for out of range dates`() { + fun `contains returns false for out of range dates`() { val start = Instant((-2L).days.inSeconds) val end = Instant(2L.days.inSeconds) @@ -90,7 +90,7 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 time interval representation`() { + fun `toString returns an ISO-8601 time interval representation`() { assertEquals( "1969-12-31T00:00Z/1970-01-02T00:00Z", (Instant((-1L).days.inSeconds) until Instant(1L.days.inSeconds)).toString() @@ -128,18 +128,18 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `String_toInstantInterval() converts an empty string to an empty interval`() { + fun `String_toInstantInterval converts an empty string to an empty interval`() { assertEquals(InstantInterval.EMPTY, "".toInstantInterval()) } @Test - fun `String_toInstantInterval() throws an exception when the format is invalid`() { + fun `String_toInstantInterval throws an exception when the format is invalid`() { assertFailsWith { "1970-01-01/1970-01-01".toInstantInterval() } assertFailsWith { "1970-01-01T00:00Z/19700101T00Z".toInstantInterval() } } @Test - fun `String_toInstantInterval() parses ISO-8601 time interval strings in extended format by default`() { + fun `String_toInstantInterval parses ISO-8601 time interval strings in extended format by default`() { assertEquals( Instant((-1L).days.inSeconds) until Instant(1L.days.inSeconds), "1969-12-31T00:00Z/1970-01-02T00:00Z".toInstantInterval() @@ -160,44 +160,44 @@ class InstantIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() returns an instant within range`() { + fun `random returns an instant within range`() { val range = Instant((-2L).days.inSeconds)..Instant(2L.days.inSeconds) val randomInstant = range.random() assertTrue { randomInstant in range } } @Test - fun `random() returns a instant within the interval`() { + fun `random returns a instant within the interval`() { val interval = Instant((-2L).days.inSeconds) until Instant(2L.days.inSeconds) assertTrue { interval.random() in interval } } @Test - fun `random() throws an exception when the interval is empty`() { + fun `random throws an exception when the interval is empty`() { assertFailsWith { InstantInterval.EMPTY.random() } } @Test - fun `random() throws an exception when the interval is not bounded`() { + fun `random throws an exception when the interval is not bounded`() { assertFailsWith { InstantInterval.UNBOUNDED.random() } assertFailsWith { InstantInterval(start = Instant.UNIX_EPOCH).random() } assertFailsWith { InstantInterval(endExclusive = Instant.UNIX_EPOCH).random() } } @Test - fun `randomOrNull() returns null when the interval is empty`() { + fun `randomOrNull returns null when the interval is empty`() { assertNull(InstantInterval.EMPTY.randomOrNull()) } @Test - fun `randomOrNull() returns null when the interval is not bounded`() { + fun `randomOrNull returns null when the interval is not bounded`() { assertNull(InstantInterval.UNBOUNDED.randomOrNull()) assertNull(InstantInterval(start = Instant.UNIX_EPOCH).randomOrNull()) assertNull(InstantInterval(endExclusive = Instant.UNIX_EPOCH).randomOrNull()) } @Test - fun `randomOrNull() returns a date within the interval`() { + fun `randomOrNull returns a date within the interval`() { val interval = Instant((2L).days.inSeconds)..Instant(2L.days.inSeconds) assertTrue { interval.randomOrNull()!! in interval } } diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/InstantProgressionTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/InstantProgressionTest.kt index bd13b6c6f..a6d1c4afe 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/InstantProgressionTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/InstantProgressionTest.kt @@ -36,7 +36,7 @@ class InstantProgressionTest : AbstractIslandTimeTest() { } @Test - fun `reversed() turns a positive progression into a negative one`() { + fun `reversed turns a positive progression into a negative one`() { val start = Instant((-2L).days.inSeconds) val end = Instant(1L.days.inSeconds) val progression = start..end step 2.days diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/OffsetDateTimeIntervalTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/OffsetDateTimeIntervalTest.kt index 7f43c7d4d..ecaa44386 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/OffsetDateTimeIntervalTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/OffsetDateTimeIntervalTest.kt @@ -45,7 +45,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within bounded range`() { + fun `contains returns true for dates within bounded range`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at UtcOffset((-4).hours) val end = Date(2019, Month.MARCH, 12) at MIDNIGHT at UtcOffset((-4).hours) @@ -56,7 +56,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded end`() { + fun `contains returns true for dates within range with unbounded end`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at UtcOffset((-4).hours) val end = DateTime.MAX at UtcOffset((-4).hours) @@ -67,7 +67,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded start`() { + fun `contains returns true for dates within range with unbounded start`() { val start = DateTime.MIN at UtcOffset((-4).hours) val end = Date(2019, Month.MARCH, 10) at MIDNIGHT at UtcOffset((-4).hours) @@ -79,7 +79,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for out of range dates`() { + fun `contains returns false for out of range dates`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at UtcOffset((-5).hours) val end = Date(2019, Month.MARCH, 12) at MIDNIGHT at UtcOffset((-4).hours) @@ -101,7 +101,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() returns a date-time within the interval`() { + fun `random returns a date-time within the interval`() { val start = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at UtcOffset((-4).hours) val end = Date(2019, Month.NOVEMBER, 20) at MIDNIGHT at UtcOffset((-5).hours) val interval = start until end @@ -111,13 +111,13 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() throws an exception when the interval is empty`() { + fun `random throws an exception when the interval is empty`() { assertFailsWith { OffsetDateTimeInterval.EMPTY.random() } assertFailsWith { OffsetDateTimeInterval.EMPTY.random(Random) } } @Test - fun `random() throws an exception when the interval is not bounded`() { + fun `random throws an exception when the interval is not bounded`() { val dateTime = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at UtcOffset((-4).hours) assertFailsWith { OffsetDateTimeInterval.UNBOUNDED.random() } assertFailsWith { OffsetDateTimeInterval.UNBOUNDED.random(Random) } @@ -126,13 +126,13 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns null when the interval is empty`() { + fun `randomOrNull returns null when the interval is empty`() { assertNull(OffsetDateTimeInterval.EMPTY.randomOrNull()) assertNull(OffsetDateTimeInterval.EMPTY.randomOrNull(Random)) } @Test - fun `randomOrNull() returns null when the interval is not bounded`() { + fun `randomOrNull returns null when the interval is not bounded`() { val dateTime = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at UtcOffset((-4).hours) assertNull(OffsetDateTimeInterval.UNBOUNDED.randomOrNull()) assertNull(OffsetDateTimeInterval.UNBOUNDED.randomOrNull(Random)) @@ -141,7 +141,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns a date-time within the interval`() { + fun `randomOrNull returns a date-time within the interval`() { val start = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at UtcOffset((-4).hours) val end = (start + 1.nanoseconds).adjustedTo(UtcOffset((-5).hours)) val interval = start until end @@ -151,12 +151,12 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `toPeriod() returns a zeroed out period when the range is empty`() { + fun `toPeriod returns a zeroed out period when the range is empty`() { assertEquals(Period.ZERO, OffsetDateTimeInterval.EMPTY.toPeriod()) } @Test - fun `toPeriod() throws an exception when the range is unbounded`() { + fun `toPeriod throws an exception when the range is unbounded`() { assertFailsWith { OffsetDateTimeInterval(endExclusive = "2018-09-10T09:15-06:00".toOffsetDateTime()).toPeriod() } @@ -367,7 +367,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `toString() returns an ISO-8601 time interval representation`() { + fun `toString returns an ISO-8601 time interval representation`() { val offset = UtcOffset((-5).hours) val start = Date(2000, 12, 31) at MIDNIGHT at offset val end = Date(2001, 1, 2) at MIDNIGHT at offset @@ -404,19 +404,19 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetDateTimeInterval() converts an empty string to an empty interval`() { + fun `String_toOffsetDateTimeInterval converts an empty string to an empty interval`() { assertEquals(OffsetDateTimeInterval.EMPTY, "".toOffsetDateTimeInterval()) } @Test - fun `String_toOffsetDateTimeInterval() throws an exception when the format is invalid`() { + fun `String_toOffsetDateTimeInterval throws an exception when the format is invalid`() { assertFailsWith { "2000-01-01/2000-01-01".toOffsetDateTimeInterval() } assertFailsWith { "2000-01-01T00:00/2000-01-01T01:00".toOffsetDateTimeInterval() } assertFailsWith { "2000-01-01T00:00+04/20000101T01-01".toOffsetDateTimeInterval() } } @Test - fun `String_toOffsetDateTimeInterval() parses ISO-8601 time interval strings in extended format by default`() { + fun `String_toOffsetDateTimeInterval parses ISO-8601 time interval strings in extended format by default`() { val offset = UtcOffset((-5).hours) val start = Date(1969, 12, 31) at MIDNIGHT at offset val end = Date(1970, 1, 2) at MIDNIGHT at offset @@ -437,7 +437,7 @@ class OffsetDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `String_toOffsetDateTimeInterval() throws an exception when required properties are missing`() { + fun `String_toOffsetDateTimeInterval throws an exception when required properties are missing`() { val customParser = groupedDateTimeParser { group { optional { diff --git a/core/src/commonTest/kotlin/io/islandtime/ranges/ZonedDateTimeIntervalTest.kt b/core/src/commonTest/kotlin/io/islandtime/ranges/ZonedDateTimeIntervalTest.kt index ba8ccc214..9ae6c17c6 100644 --- a/core/src/commonTest/kotlin/io/islandtime/ranges/ZonedDateTimeIntervalTest.kt +++ b/core/src/commonTest/kotlin/io/islandtime/ranges/ZonedDateTimeIntervalTest.kt @@ -43,7 +43,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within bounded range`() { + fun `contains returns true for dates within bounded range`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at nyZone val end = Date(2019, Month.MARCH, 12) at MIDNIGHT at nyZone @@ -54,7 +54,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded end`() { + fun `contains returns true for dates within range with unbounded end`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at nyZone val end = DateTime.MAX at nyZone @@ -65,7 +65,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns true for dates within range with unbounded start`() { + fun `contains returns true for dates within range with unbounded start`() { val start = DateTime.MIN at nyZone val end = Date(2019, Month.MARCH, 10) at MIDNIGHT at nyZone @@ -77,7 +77,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `contains() returns false for out of range dates`() { + fun `contains returns false for out of range dates`() { val start = Date(2019, Month.MARCH, 10) at MIDNIGHT at nyZone val end = Date(2019, Month.MARCH, 12) at MIDNIGHT at nyZone @@ -99,7 +99,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() returns a date-time within the interval`() { + fun `random returns a date-time within the interval`() { val start = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at nyZone val end = Date(2019, Month.NOVEMBER, 2) at MIDNIGHT at nyZone val interval = start until end @@ -109,13 +109,13 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `random() throws an exception when the interval is empty`() { + fun `random throws an exception when the interval is empty`() { assertFailsWith { ZonedDateTimeInterval.EMPTY.random() } assertFailsWith { ZonedDateTimeInterval.EMPTY.random(Random) } } @Test - fun `random() throws an exception when the interval is not bounded`() { + fun `random throws an exception when the interval is not bounded`() { val dateTime = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at nyZone assertFailsWith { ZonedDateTimeInterval.UNBOUNDED.random() } assertFailsWith { ZonedDateTimeInterval.UNBOUNDED.random(Random) } @@ -124,13 +124,13 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns null when the interval is empty`() { + fun `randomOrNull returns null when the interval is empty`() { assertNull(ZonedDateTimeInterval.EMPTY.randomOrNull()) assertNull(ZonedDateTimeInterval.EMPTY.randomOrNull(Random)) } @Test - fun `randomOrNull() returns null when the interval is not bounded`() { + fun `randomOrNull returns null when the interval is not bounded`() { val dateTime = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at nyZone assertNull(ZonedDateTimeInterval.UNBOUNDED.randomOrNull()) assertNull(ZonedDateTimeInterval.UNBOUNDED.randomOrNull(Random)) @@ -139,7 +139,7 @@ class ZonedDateTimeIntervalTest : AbstractIslandTimeTest() { } @Test - fun `randomOrNull() returns a date-time within the interval`() { + fun `randomOrNull returns a date-time within the interval`() { val start = Date(2019, Month.NOVEMBER, 1) at MIDNIGHT at nyZone val end = (start + 1.nanoseconds).adjustedTo(TimeZone("Europe/London")) val interval = start until end diff --git a/core/src/darwinMain/kotlin/io/islandtime/zone/TimeZoneRules.kt b/core/src/darwinMain/kotlin/io/islandtime/zone/TimeZoneRules.kt index e6dbec139..e00c71ece 100644 --- a/core/src/darwinMain/kotlin/io/islandtime/zone/TimeZoneRules.kt +++ b/core/src/darwinMain/kotlin/io/islandtime/zone/TimeZoneRules.kt @@ -99,7 +99,6 @@ private class DarwinTimeZoneRules(timeZone: NSTimeZone) : TimeZoneRules { override val hasFixedOffset: Boolean get() = timeZone.nextDaylightSavingTimeTransitionAfterDate(NSDate.distantPast) == null - @OptIn(ExperimentalStdlibApi::class) private fun findTransitionsIn(year: Int): List { val startDateComponents = NSDateComponents().also { it.year = (year - 1).convert() diff --git a/core/src/darwinTest/kotlin/io/islandtime/format/DarwinTimeZoneTextProviderTest.kt b/core/src/darwinTest/kotlin/io/islandtime/format/DarwinTimeZoneTextProviderTest.kt index 78d26ed6d..7f57515c8 100644 --- a/core/src/darwinTest/kotlin/io/islandtime/format/DarwinTimeZoneTextProviderTest.kt +++ b/core/src/darwinTest/kotlin/io/islandtime/format/DarwinTimeZoneTextProviderTest.kt @@ -11,7 +11,7 @@ class DarwinTimeZoneTextProviderTest : AbstractIslandTimeTest() { private val en_US = "en-US".toLocale() @Test - fun `timeZoneTextFor() returns a localized string for generic styles`() { + fun `timeZoneTextFor returns a localized string for generic styles`() { val zone = TimeZone("America/New_York") assertEquals( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c90f65126..19a81b948 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -kotlin = "1.5.31" +kotlin = "1.6.0" dokka = "1.5.31" serialization = "1.3.0" atomicfu = "0.16.3" diff --git a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/descriptions/TemporalUnitDescription.kt b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/descriptions/TemporalUnitDescription.kt index 4e95d0341..f73e3c320 100644 --- a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/descriptions/TemporalUnitDescription.kt +++ b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/descriptions/TemporalUnitDescription.kt @@ -1,6 +1,5 @@ package io.islandtime.codegen.descriptions -@OptIn(ExperimentalStdlibApi::class) enum class TemporalUnitDescription( val pluralName: String, val conversionFactor: Int, @@ -85,7 +84,6 @@ data class TemporalUnitConversion( fun isNecessary() = operator != ConversionOperator.NONE - @OptIn(ExperimentalStdlibApi::class) val constantName: String by lazy(LazyThreadSafetyMode.NONE) { val (smallerUnit, largerUnit) = orderedFromSmallerToLargerUnit() "${smallerUnit.pluralName}_PER_${largerUnit.singularName}".uppercase() @@ -114,15 +112,6 @@ data class TemporalUnitConversion( val valueFitsInInt: Boolean get() = constantValue in Int.MIN_VALUE..Int.MAX_VALUE - fun requiresSafeMultiplicationForInt(): Boolean { - return try { - Math.multiplyExact(Int.MIN_VALUE.toLong(), constantValue) - false - } catch (e: ArithmeticException) { - true - } - } - private fun orderedFromSmallerToLargerUnit() = if (fromUnit <= toUnit) { fromUnit to toUnit } else { diff --git a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/dsl/CodeWriterDsl.kt b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/dsl/CodeWriterDsl.kt index 51e46f95e..f48eb4aaf 100644 --- a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/dsl/CodeWriterDsl.kt +++ b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/dsl/CodeWriterDsl.kt @@ -21,10 +21,20 @@ class FileBuilder( builder.addAliasedImport(className, `as`) } + fun aliasedImport(memberName: MemberName, `as`: String) { + builder.addAliasedImport(memberName, `as`) + } + + @JvmName("aliasedClassImports") fun aliasedImports(vararg imports: Pair) { imports.forEach { (className, `as`) -> aliasedImport(className, `as`) } } + @JvmName("aliasedMemberImports") + fun aliasedImports(vararg imports: Pair) { + imports.forEach { (memberName, `as`) -> aliasedImport(memberName, `as`) } + } + fun annotation(annotation: KClass<*>, block: AnnotationBuilder.() -> Unit = {}) { annotation(annotation.asClassName(), block) } diff --git a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/generators/TemporalUnitGenerator.kt b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/generators/TemporalUnitGenerator.kt index 8f68d8f05..bfeb3f395 100644 --- a/tools/code-generator/src/main/kotlin/io/islandtime/codegen/generators/TemporalUnitGenerator.kt +++ b/tools/code-generator/src/main/kotlin/io/islandtime/codegen/generators/TemporalUnitGenerator.kt @@ -37,12 +37,17 @@ enum class PlusOrMinusOperator( private val KOTLIN_DURATION_CLASS_NAME = ClassName("kotlin.time", "Duration") private val KOTLIN_DURATION_UNIT_CLASS_NAME = ClassName("kotlin.time", "DurationUnit") -private val EXPERIMENTAL_TIME_CLASS_NAME = ClassName("kotlin.time", "ExperimentalTime") private val KOTLIN_CONTRACT_CLASS_NAME = ClassName("kotlin.contracts", "contract") private val KOTLIN_INVOCATION_KIND_CLASS_NAME = ClassName("kotlin.contracts", "InvocationKind") private val OPT_IN_CLASS_NAME = ClassName("kotlin", "OptIn") private val EXPERIMENTAL_CONTRACTS_CLASS_NAME = ClassName("kotlin.contracts", "ExperimentalContracts") +private val TemporalUnitDescription.kotlinDurationUnitPropertyClassName + get() = MemberName( + enclosingClassName = ClassName("kotlin.time", "Duration", "Companion"), + simpleName = lowerPluralName, + ) + private fun KClass<*>.literalValueString(value: Long) = when (this) { Int::class -> "$value" Long::class -> "${value}L" @@ -68,6 +73,7 @@ private fun buildTemporalUnitFile(description: TemporalUnitDescription) = file( KOTLIN_DURATION_CLASS_NAME to "KotlinDuration", KOTLIN_DURATION_UNIT_CLASS_NAME to "KotlinDurationUnit" ) + aliasedImport(description.kotlinDurationUnitPropertyClassName, "kotlin${description.pluralName}") } typeAlias(description.deprecatedIntName, description.className) { @@ -167,12 +173,11 @@ private fun buildTemporalUnitFile(description: TemporalUnitDescription) = file( if (description.isTimeBased) { function("toKotlinDuration") { kdoc { "Converts this duration to a [${KOTLIN_DURATION_CLASS_NAME.canonicalName}]." } - annotation(EXPERIMENTAL_TIME_CLASS_NAME) returns(KOTLIN_DURATION_CLASS_NAME) code { - using("kotlinDuration", KOTLIN_DURATION_CLASS_NAME) - "return %kotlinDuration:T.${description.lowerPluralName}(${description.valueName})" + using("kotlinDurationUnitProperty", description.kotlinDurationUnitPropertyClassName) + "return ${description.valueName}.%kotlinDurationUnitProperty:M" } } } @@ -306,7 +311,6 @@ private fun buildTemporalUnitFile(description: TemporalUnitDescription) = file( if (description.isTimeBased) { function("toIsland${description.pluralName}") { kdoc { "Converts this duration to Island Time [${description.pluralName}]." } - annotation(EXPERIMENTAL_TIME_CLASS_NAME) receiver(KOTLIN_DURATION_CLASS_NAME) returns(description.className) code { @@ -664,8 +668,8 @@ private fun ClassBuilder.buildToComponentValuesFunctions(thisUnit: TemporalUnitD private fun CodeBlockBuilder.exactlyOnceContractCode(parameter: String) { using( - "contract" to ClassName("kotlin.contracts", "contract"), - "invocationKind" to ClassName("kotlin.contracts", "InvocationKind") + "contract" to KOTLIN_CONTRACT_CLASS_NAME, + "invocationKind" to KOTLIN_INVOCATION_KIND_CLASS_NAME ) +"%contract:T { callsInPlace($parameter, %invocationKind:T.EXACTLY_ONCE) }" }