Skip to content

Commit 50dbdf2

Browse files
Add linux native sample project
1 parent 82aba7f commit 50dbdf2

File tree

13 files changed

+222
-7
lines changed

13 files changed

+222
-7
lines changed

deps.kt

ktjvmsample/src/main/kotlin/pl/mareklangiewicz/uspeksample/Main.kt renamed to ktjvmsample/src/main/kotlin/pl/mareklangiewicz/ktjvmsample/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pl.mareklangiewicz.uspeksample
1+
package pl.mareklangiewicz.ktjvmsample
22

33
fun main(args: Array<String>) {
44
val calc = MicroCalc(0)

ktjvmsample/src/main/kotlin/pl/mareklangiewicz/uspeksample/MicroCalc.kt renamed to ktjvmsample/src/main/kotlin/pl/mareklangiewicz/ktjvmsample/MicroCalc.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pl.mareklangiewicz.uspeksample
1+
package pl.mareklangiewicz.ktjvmsample
22

33

44
class MicroCalc(var result: Int) {

ktjvmsample/src/test/kotlin/pl/mareklangiewicz/uspeksample/MicroCalcTest.kt renamed to ktjvmsample/src/test/kotlin/pl/mareklangiewicz/ktjvmsample/MicroCalcTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pl.mareklangiewicz.uspeksample
1+
package pl.mareklangiewicz.ktjvmsample
22

33
import org.junit.jupiter.api.TestFactory
44
import pl.mareklangiewicz.uspek.eq

ktjvmsample/src/test/kotlin/pl/mareklangiewicz/uspeksample/USpekJUnitFactoryNestedTest.kt renamed to ktjvmsample/src/test/kotlin/pl/mareklangiewicz/ktjvmsample/USpekJUnitFactoryNestedTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
package pl.mareklangiewicz.uspeksample
1+
package pl.mareklangiewicz.ktjvmsample
22

33
import org.junit.jupiter.api.TestFactory
44
import pl.mareklangiewicz.uspek.o
55
import pl.mareklangiewicz.uspek.ox
66
import pl.mareklangiewicz.uspek.uspekTestFactory
7-
import pl.mareklangiewicz.uspeksample.MicroCalc
87

98
class USpekJUnitFactoryNestedTest {
109

ktlinuxsample/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/build
2+
/out
3+
/.idea
4+
/.gradle
5+
/local.properties

ktlinuxsample/build.gradle.kts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
kotlin("multiplatform")
3+
}
4+
5+
repositories {
6+
// mavenLocal()
7+
maven("https://jitpack.io")
8+
}
9+
10+
kotlin {
11+
val hostOs = System.getProperty("os.name")
12+
val isMingwX64 = hostOs.startsWith("Windows")
13+
val nativeTarget = when {
14+
hostOs == "Mac OS X" -> macosX64("native")
15+
hostOs == "Linux" -> linuxX64("native")
16+
isMingwX64 -> mingwX64("native")
17+
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
18+
}
19+
20+
nativeTarget.apply {
21+
binaries {
22+
executable {
23+
entryPoint = "pl.mareklangiewicz.ktlinuxsample.main"
24+
}
25+
}
26+
}
27+
sourceSets {
28+
val commonMain by getting
29+
val commonTest by getting {
30+
dependencies {
31+
// implementation(project(":uspek"))
32+
implementation(Deps.uspek)
33+
}
34+
}
35+
val nativeMain by getting
36+
val nativeTest by getting
37+
}
38+
}
39+
40+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package pl.mareklangiewicz.ktlinuxsample
2+
3+
val EXAMPLE_TEXT = "Example text from ktlinuxsample commonMain code"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package pl.mareklangiewicz.ktlinuxsample
2+
3+
fun main(args: Array<String>) {
4+
println(EXAMPLE_TEXT)
5+
val calc = MicroCalc(0)
6+
println(calc.result)
7+
calc.add(10)
8+
println(calc.result)
9+
}
10+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package pl.mareklangiewicz.ktlinuxsample
2+
3+
4+
class MicroCalc(var result: Int) {
5+
fun add(x: Int) { result += x }
6+
fun multiplyBy(x: Int) { result *= x }
7+
fun ensureResultIs(expectedResult: Int) =
8+
check(result == expectedResult) { "result is not: $expectedResult; it is actually: $result" }
9+
}

0 commit comments

Comments
 (0)