Skip to content

Commit

Permalink
Merge branch 'arrow-2' into arrow2-guarentee-case-test
Browse files Browse the repository at this point in the history
  • Loading branch information
serras authored Oct 25, 2023
2 parents aa16aa7 + 6daa91a commit dcdd915
Show file tree
Hide file tree
Showing 48 changed files with 1,018 additions and 1,254 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
- name: jvmTest (K2 enabled)
uses: gradle/gradle-build-action@v2
with:
arguments: "jvmTest -Pkotlin_version=1.9.30-dev-2548 -Pkotlin_repo_url=https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap -Pkotlin_language_version=2.0"
arguments: "jvmTest -Pkotlin_version=2.0.0-dev-5387 -Pkotlin_repo_url=https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap -Pkotlin_language_version=2.0"

- name: Upload reports
if: failure()
Expand Down
19 changes: 2 additions & 17 deletions arrow-libs/core/arrow-annotations/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,15 @@ spotless {
}
}

apply(from = property("ANIMALSNIFFER_MPP"))

kotlin {
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlin.stdlibCommon)
}
}
jvmMain {
dependencies {
implementation(libs.kotlin.stdlib)
}
}
jvmTest {
dependencies {
runtimeOnly(libs.kotest.runnerJUnit5)
}
}
jsMain {
dependencies {
implementation(libs.kotlin.stdlibJS)
}
}
}

jvm {
Expand All @@ -45,5 +32,3 @@ kotlin {
}
}
}

apply(from = property("ANIMALSNIFFER_MPP"))
45 changes: 7 additions & 38 deletions arrow-libs/core/arrow-atomic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile


plugins {
id(libs.plugins.kotlin.multiplatform.get().pluginId)
alias(libs.plugins.arrowGradleConfig.kotlin)
alias(libs.plugins.arrowGradleConfig.publish)

alias(libs.plugins.kotest.multiplatform)
alias(libs.plugins.kotlinx.kover)
alias(libs.plugins.spotless)
}
Expand All @@ -25,51 +22,19 @@ kotlin {
sourceSets {
commonMain {
dependencies {
api(libs.kotlin.stdlibCommon)
}
}

commonTest {
dependencies {
implementation(projects.arrowFxCoroutines)
implementation(libs.kotest.frameworkEngine)
implementation(libs.kotest.assertionsCore)
implementation(libs.kotest.property)
}
}

jvmTest {
dependencies {
runtimeOnly(libs.kotest.runnerJUnit5)
}
}

jvmMain {
dependencies {
implementation(libs.kotlin.stdlib)
}
}

jsMain {
dependencies {
implementation(libs.kotlin.stdlibJS)
api(libs.kotlin.stdlib)
}
}

commonTest {
dependencies {
implementation(projects.arrowFxCoroutines)
implementation(libs.kotest.frameworkEngine)
implementation(libs.kotlin.test)
implementation(libs.coroutines.test)
implementation(libs.kotest.assertionsCore)
implementation(libs.kotest.property)
}
}

jvmTest {
dependencies {
runtimeOnly(libs.kotest.runnerJUnit5)
}
}
}

jvm {
Expand All @@ -86,3 +51,7 @@ tasks.withType<KotlinCompile>().configureEach {
freeCompilerArgs = freeCompilerArgs + "-Xexpect-actual-classes"
}
}

tasks.withType<Test> {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
package arrow.atomic

import arrow.fx.coroutines.parMap
import io.kotest.core.spec.style.StringSpec
import kotlin.test.Test
import kotlinx.coroutines.test.runTest
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.boolean
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.long
import io.kotest.property.arbitrary.string
import io.kotest.property.checkAll
import kotlin.coroutines.Continuation
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn

class AtomicBooleanTest : StringSpec({
class AtomicBooleanTest {

"set get - successful" {
@Test
fun setGetSuccessful() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val r = AtomicBoolean(x)
r.value = y
r.value shouldBe y
}
}

"update get - successful" {
@Test
fun updateGetSuccessful() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val r = AtomicBoolean(x)
r.update { y }
r.value shouldBe y
}
}

"getAndSet - successful" {
@Test
fun getAndSetSuccessful() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val ref = AtomicBoolean(x)
ref.getAndSet(y) shouldBe x
ref.value shouldBe y
}
}

"getAndUpdate - successful" {
@Test
fun getAndUpdateSuccessful() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val ref = AtomicBoolean(x)
ref.getAndUpdate { y } shouldBe x
ref.value shouldBe y
}
}

"updateAndGet - successful" {
@Test
fun updateAndGetSuccessful() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val ref = AtomicBoolean(x)
ref.updateAndGet {
Expand All @@ -57,15 +56,17 @@ class AtomicBooleanTest : StringSpec({
}
}

"tryUpdate - modification occurs successfully" {
@Test
fun tryUpdateModificationOccursSuccessfully() = runTest {
checkAll(Arb.boolean()) { x ->
val ref = AtomicBoolean(x)
ref.tryUpdate { !it }
ref.value shouldBe !x
}
}

"tryUpdate - should fail to update if modification has occurred" {
@Test
fun tryUpdateShouldFailToUpdateIfModificationHasOccurred() = runTest {
checkAll(Arb.boolean()) { x ->
val ref = AtomicBoolean(x)
ref.tryUpdate {
Expand All @@ -75,7 +76,8 @@ class AtomicBooleanTest : StringSpec({
}
}

"consistent set update on strings" {
@Test
fun consistentSetUpdateOnStrings() = runTest {
checkAll(Arb.boolean(), Arb.boolean()) { x, y ->
val set = {
val r = AtomicBoolean(x)
Expand All @@ -92,4 +94,4 @@ class AtomicBooleanTest : StringSpec({
set() shouldBe update()
}
}
})
}
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
package arrow.atomic

import arrow.fx.coroutines.parMap
import io.kotest.core.spec.style.StringSpec
import kotlin.test.Test
import kotlinx.coroutines.test.runTest
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.string
import io.kotest.property.checkAll
import kotlin.coroutines.Continuation
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.coroutines.intrinsics.startCoroutineUninterceptedOrReturn

class AtomicIntTest : StringSpec({
class AtomicIntTest {

"set get - successful" {
@Test
fun setGetSuccessful() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val r = AtomicInt(x)
r.value = y
r.value shouldBe y
}
}

"update get - successful" {
@Test
fun updateGetSuccessful() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val r = AtomicInt(x)
r.update { y }
r.value shouldBe y
}
}

"getAndSet - successful" {
@Test
fun getAndSetSuccessful() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val ref = AtomicInt(x)
ref.getAndSet(y) shouldBe x
ref.value shouldBe y
}
}

"getAndUpdate - successful" {
@Test
fun getAndUpdateSuccessful() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val ref = AtomicInt(x)
ref.getAndUpdate { y } shouldBe x
ref.value shouldBe y
}
}

"updateAndGet - successful" {
@Test
fun updateAndGetSuccessful() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val ref = AtomicInt(x)
ref.updateAndGet {
Expand All @@ -55,15 +57,17 @@ class AtomicIntTest : StringSpec({
}
}

"tryUpdate - modification occurs successfully" {
@Test
fun tryUpdateModificationOccursSuccessfully() = runTest {
checkAll(Arb.int()) { x ->
val ref = AtomicInt(x)
ref.tryUpdate { it + 1 }
ref.value shouldBe x + 1
}
}

"tryUpdate - should fail to update if modification has occurred" {
@Test
fun tryUpdateShouldFailToUpdateIfModificationHasOccurred() = runTest {
checkAll(Arb.int()) { x ->
val ref = AtomicInt(x)
ref.tryUpdate {
Expand All @@ -73,7 +77,8 @@ class AtomicIntTest : StringSpec({
}
}

"consistent set update on strings" {
@Test
fun consistentSetUpdateOnStrings() = runTest {
checkAll(Arb.int(), Arb.int()) { x, y ->
val set = {
val r = AtomicInt(x)
Expand All @@ -91,11 +96,11 @@ class AtomicIntTest : StringSpec({
}
}

"concurrent modifications" {
val finalValue = 50_000
@Test
fun concurrentModifications() = runTestWithDelay {
val finalValue = stackSafeIteration()
val r = AtomicInt(0)
(0 until finalValue).parMap { r.update { it + 1 } }
r.value shouldBe finalValue
}
}
)
Loading

0 comments on commit dcdd915

Please sign in to comment.