Skip to content
Merged
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts → build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ repositories {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.6.21")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ kotlin {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
js(BOTH) {
browser { }
js(IR) {
browser {
useEsModules()
}
binaries.executable()
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
Expand Down Expand Up @@ -83,7 +85,7 @@ publishing {
repositories {
maven {
name = "local"
url = uri("$buildDir/repo")
url = uri("${layout.buildDirectory}/repo")
}
}
publications.filterIsInstance<MavenPublication>().forEach {
Expand Down
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

repositories {
mavenCentral()
gradlePluginPortal()
}

// Publish configuration.
// For signing and publishing to work, a 'publish.properties' file needs to be added to the root containing:
// The OpenPGP credentials to sign all artifacts:
Expand All @@ -16,7 +21,7 @@ if (publishPropertiesFile.exists()) {
publishProperties.load(java.io.FileInputStream(publishPropertiesFile))
}
group = "io.github.whathecode.kotlinx.interval"
version = "1.0.0-alpha.4"
version = "1.0.0-alpha.5"
nexusPublishing {
repositories {
sonatype {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.js.generate.executable.default=false
kotlin.mpp.applyDefaultHierarchyTemplate=false

# Prevent out of memory errors.
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1024m
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1,781 changes: 1,315 additions & 466 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions kotlinx.interval.datetime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ kotlin {
commonMain {
dependencies {
api(project(":kotlinx-interval"))
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
}
}
commonTest {
dependencies {
implementation(project(":kotlinx-interval-test"))
implementation(project(":kotlinx-interval-testcases"))
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions kotlinx.interval.datetime/src/commonTest/kotlin/Readme.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress( "UNUSED_VARIABLE" )

package io.github.whathecode.kotlinx.interval.datetime

import kotlinx.datetime.Clock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ abstract class IntervalTest<T : Comparable<T>, TSize : Comparable<TSize>>(
reversed.forEach { assertTrue( it.isReversed ) }
}

@Test
fun lowerBound_and_upperBound()
{
val notReversed = createAllInclusionTypeIntervals( a, b )
notReversed.forEach {
assertEquals( a, it.lowerBound )
assertEquals( it.isStartIncluded, it.isLowerBoundIncluded )
assertEquals( b, it.upperBound )
assertEquals( it.isEndIncluded, it.isUpperBoundIncluded )
}

val reversed = createAllInclusionTypeIntervals( b, a )
reversed.forEach {
assertEquals( a, it.lowerBound )
assertEquals( it.isEndIncluded, it.isLowerBoundIncluded )
assertEquals( b, it.upperBound )
assertEquals( it.isStartIncluded, it.isUpperBoundIncluded )
}

val single = createClosedInterval( a, a )
assertEquals( a, single.lowerBound )
assertEquals( a, single.upperBound )
assertTrue( single.isLowerBoundIncluded )
assertTrue( single.isUpperBoundIncluded )
}

@Test
fun size_for_normal_and_reverse_intervals_is_the_same()
{
Expand Down Expand Up @@ -144,6 +170,192 @@ abstract class IntervalTest<T : Comparable<T>, TSize : Comparable<TSize>>(
openIntervals.forEach { assertTrue( a !in it && b !in it ) }
}

@Test
fun minus_for_interval_lying_within()
{
val adIntervals = createAllInclusionTypeIntervals( a, d )
val bcIntervals = createAllInclusionTypeIntervals( b, c )

for ( ad in adIntervals ) for ( bc in bcIntervals )
{
val expected = setOf(
createInterval( a, ad.isStartIncluded, b, !bc.isStartIncluded ),
createInterval( c, !bc.isEndIncluded, d, ad.isEndIncluded )
)
assertEquals( expected, (ad - bc).toSet() )
}
}

@Test
fun minus_for_partial_overlapping_interval()
{
val acIntervals = createAllInclusionTypeIntervals( a, c )
val bdIntervals = createAllInclusionTypeIntervals( b, d )

for ( ac in acIntervals ) for ( bd in bdIntervals )
{
assertEquals(
createInterval( a, ac.isStartIncluded, b, !bd.isStartIncluded ),
(ac - bd).singleOrNull()
)
}
}

@Test
fun minus_for_matching_interval()
{
val abIntervals = createAllInclusionTypeIntervals( a, b )

for ( ab in abIntervals )
assertTrue( (ab - ab).isEmpty() )
}

@Test
fun minus_for_encompassing_interval()
{
val bcIntervals = createAllInclusionTypeIntervals( b, c )
val adIntervals = createAllInclusionTypeIntervals( a, d )

for ( bc in bcIntervals ) for ( ad in adIntervals )
assertTrue( (bc - ad).isEmpty() )
}

@Test
fun minus_for_nonoverlapping_interval()
{
val abIntervals = createAllInclusionTypeIntervals( a, b )
val cdIntervals = createAllInclusionTypeIntervals( c, d )

for ( ab in abIntervals ) for ( cd in cdIntervals )
assertEquals( ab, (ab - cd).singleOrNull() )
}

@Test
fun minus_for_overlapping_intervals_with_touching_endpoints()
{
val abWithA = createClosedInterval( a, b )
val abWithoutA = createInterval( a, false, b, true )
assertEquals(
createClosedInterval( a, a ),
(abWithA - abWithoutA).singleOrNull()
)

val abWithB = createClosedInterval( a, b )
val abWithoutB = createInterval ( a, true, b, false )
assertEquals(
createClosedInterval( b, b ),
(abWithB - abWithoutB).singleOrNull()
)

val abClosed = createClosedInterval( a, b )
val abOpen = createOpenInterval( a, b )
assertEquals(
setOf( createClosedInterval( a, a ), createClosedInterval( b, b ) ),
(abClosed - abOpen).toSet()
)
}

@Test
fun minus_for_neighbouring_interval_with_touching_endpoints()
{
val abWithB = createClosedInterval( a, b )
val bcWithB = createClosedInterval( b, c )
assertEquals(
createInterval( a, true, b, false ),
(abWithB - bcWithB).singleOrNull()
)

val bcWithoutB = createOpenInterval( b, c )
assertEquals( abWithB, (abWithB - bcWithoutB).singleOrNull() )
}

@Test
fun plus_for_interval_lying_within()
{
val adIntervals = createAllInclusionTypeIntervals( a, d )
val bcIntervals = createAllInclusionTypeIntervals( b, c )

for ( ad in adIntervals ) for ( bc in bcIntervals )
assertEquals( ad, (ad + bc).singleOrNull() )
}

@Test
fun plus_for_partial_overlapping_interval()
{
val acIntervals = createAllInclusionTypeIntervals( a, c )
val bdIntervals = createAllInclusionTypeIntervals( b, d )

for ( ac in acIntervals ) for ( bd in bdIntervals )
{
assertEquals(
createInterval( a, ac.isStartIncluded, d, bd.isEndIncluded ),
(ac + bd).singleOrNull()
)
}
}

@Test
fun plus_for_matching_interval()
{
val abIntervals = createAllInclusionTypeIntervals( a, b )

for ( ab in abIntervals )
assertEquals( ab, (ab + ab).singleOrNull() )
}

@Test
fun plus_for_encompassing_interval()
{
val bcIntervals = createAllInclusionTypeIntervals( b, c )
val adIntervals = createAllInclusionTypeIntervals( a, d )

for ( bc in bcIntervals ) for ( ad in adIntervals )
assertEquals( ad, (bc + ad).singleOrNull() )
}

@Test
fun plus_for_nonoverlapping_interval()
{
val abIntervals = createAllInclusionTypeIntervals( a, b )
val cdIntervals = createAllInclusionTypeIntervals( c, d )

for ( ab in abIntervals ) for ( cd in cdIntervals )
assertEquals( setOf( ab, cd ), (ab + cd).toSet() )
}

@Test
fun plus_for_overlapping_intervals_with_touching_endpoints()
{
val abWithA = createClosedInterval( a, b )
val abWithoutA = createInterval( a, false, b, true )
assertEquals( abWithA, (abWithA + abWithoutA).singleOrNull() )

val abWithB = createClosedInterval( a, b )
val abWithoutB = createInterval ( a, true, b, false )
assertEquals( abWithB, (abWithB + abWithoutB).singleOrNull() )

val abClosed = createClosedInterval( a, b )
val abOpen = createOpenInterval( a, b )
assertEquals( abClosed, (abClosed + abOpen).singleOrNull() )
}

@Test
fun plus_for_neighbouring_interval_with_touching_endpoints()
{
val abWithB = createClosedInterval( a, b )
val bcWithB = createClosedInterval( b, c )
assertEquals(
createClosedInterval( a, c ),
(abWithB + bcWithB).singleOrNull()
)

val bcWithoutB = createOpenInterval( b, c )
assertEquals(
createInterval( a, true, c, false ),
(abWithB + bcWithoutB).singleOrNull()
)
}

@Test
fun intersects_for_fully_contained_intervals()
{
Expand Down
2 changes: 1 addition & 1 deletion kotlinx.interval/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kotlin {
sourceSets {
commonTest {
dependencies {
implementation(project(":kotlinx-interval-test"))
implementation(project(":kotlinx-interval-testcases"))
}
}
}
Expand Down
Loading