Skip to content

Commit 2e8a11f

Browse files
committed
mpp-sample added
1 parent d8b25ef commit 2e8a11f

File tree

6 files changed

+79
-27
lines changed

6 files changed

+79
-27
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
buildscript {
6+
repositories {
7+
mavenLocal()
8+
}
9+
10+
dependencies {
11+
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.22.0-SNAPSHOT")
12+
}
13+
}
14+
15+
plugins {
16+
kotlin("multiplatform") version "1.9.10"
17+
}
18+
19+
apply(plugin = "kotlinx-atomicfu")
20+
21+
repositories {
22+
mavenLocal()
23+
mavenCentral()
24+
}
25+
26+
kotlin {
27+
jvm {
28+
jvmToolchain(8)
29+
withJava()
30+
testRuns.named("test") {
31+
executionTask.configure {
32+
useJUnitPlatform()
33+
}
34+
}
35+
}
36+
js {
37+
nodejs()
38+
}
39+
val hostOs = System.getProperty("os.name")
40+
val isArm64 = System.getProperty("os.arch") == "aarch64"
41+
val isMingwX64 = hostOs.startsWith("Windows")
42+
val nativeTarget = when {
43+
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
44+
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
45+
hostOs == "Linux" && isArm64 -> linuxArm64("native")
46+
hostOs == "Linux" && !isArm64 -> linuxX64("native")
47+
isMingwX64 -> mingwX64("native")
48+
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
49+
}
50+
51+
sourceSets {
52+
val commonMain by getting
53+
val commonTest by getting {
54+
dependencies {
55+
implementation(kotlin("test"))
56+
}
57+
}
58+
}
59+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import kotlinx.atomicfu.*
2+
3+
class IntArithmetic {
4+
private val _x = atomic(0)
5+
val x get() = _x.value
6+
7+
fun doWork(finalValue: Int) {
8+
check(x == 0)
9+
_x.getAndSet(3)
10+
check(x == 3)
11+
_x.compareAndSet(3, finalValue)
12+
check(x == finalValue)
13+
}
14+
}

integration-testing/mpp-sample/src/main/commonTest/kotlin/SampleTest.kt renamed to integration-testing/mpp-sample/commonTest/kotlin/IntArithmeticTest.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
/*
2-
* Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3-
*/
4-
51
import kotlin.test.*
62

7-
class ArithmeticTest {
3+
class IntArithmeticTest {
84

95
@Test
106
fun testInt() {

integration-testing/mpp-sample/settings.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pluginManagement {
22
repositories {
3-
google()
4-
gradlePluginPortal()
3+
mavenLocal()
54
mavenCentral()
5+
gradlePluginPortal()
66
}
77
}
88

integration-testing/mpp-sample/src/main/commonMain/kotlin/Sample.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

integration-testing/settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ pluginManagement {
77
}
88
}
99

10-
rootProject.name = "kotlinx-atomicfu-integration-testing"
10+
rootProject.name = "kotlinx-atomicfu-integration-testing"
11+
include 'mpp'
12+

0 commit comments

Comments
 (0)