Skip to content

Commit 1b1ccda

Browse files
committed
WIP: introduced simple JVM-only project in integration tests
1 parent de38382 commit 1b1ccda

File tree

7 files changed

+77
-12
lines changed

7 files changed

+77
-12
lines changed

integration-testing/build.gradle

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
buildscript {
32

43
/*
@@ -49,11 +48,6 @@ repositories {
4948
mavenCentral()
5049
}
5150

52-
java {
53-
sourceCompatibility = JavaVersion.VERSION_1_8
54-
targetCompatibility = JavaVersion.VERSION_1_8
55-
}
56-
5751
dependencies {
5852
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
5953
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
@@ -78,12 +72,10 @@ task mavenTest(type: Test) {
7872
classpath = sourceSet.runtimeClasspath
7973
}
8074

81-
compileTestKotlin {
82-
kotlinOptions.jvmTarget = "1.8"
75+
kotlin {
76+
jvmToolchain(11)
8377
}
8478

85-
compileKotlin {
86-
kotlinOptions {
87-
jvmTarget = "1.8"
88-
}
79+
check {
80+
dependsOn([mavenTest, 'jvm-sample:build'])
8981
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
buildscript {
2+
val atomicfu_version = rootProject.properties["atomicfu_version"]
3+
val kotlin_version = rootProject.properties["kotlin_version"]
4+
5+
repositories {
6+
mavenLocal()
7+
}
8+
9+
dependencies {
10+
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version")
11+
}
12+
}
13+
14+
plugins {
15+
kotlin("jvm") version "1.9.0"
16+
}
17+
18+
apply(plugin = "kotlinx-atomicfu")
19+
20+
repositories {
21+
mavenLocal()
22+
mavenCentral()
23+
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
24+
}
25+
26+
dependencies {
27+
implementation(kotlin("stdlib"))
28+
implementation(kotlin("test-junit"))
29+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kotlin_version=1.9.0
2+
atomicfu_version=0.22.0-SNAPSHOT
3+
4+
kotlinx.atomicfu.enableJvmIrTransformation=true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "jvm-sample"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import kotlinx.atomicfu.*
6+
7+
class IntArithmetic {
8+
private val _x = atomic(0)
9+
val x get() = _x.value
10+
11+
fun doWork() {
12+
_x.getAndSet(3)
13+
_x.compareAndSet(3, 8)
14+
}
15+
}
16+
17+
// minimal example that forces ASM to call AtomicFUTransformer.CW.getCommonSuperClass
18+
private fun checkTransformerFindCommonSuperClass() {
19+
val (a, b) = 0 to 1
20+
if (a == 0) {
21+
val c = listOf(a, b)
22+
}
23+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import kotlin.test.*
6+
7+
class ArithmeticTest {
8+
@Test
9+
fun testInt() {
10+
val a = IntArithmetic()
11+
a.doWork()
12+
check(a.x == 1234)
13+
}
14+
}

integration-testing/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ pluginManagement {
77
}
88
}
99

10+
include 'jvm-sample'
11+
1012
rootProject.name = "kotlinx-atomicfu-integration-testing"

0 commit comments

Comments
 (0)