Test that typealias works with Gradle
#KT-13204 Obsolete
This commit is contained in:
+23
@@ -4,6 +4,7 @@ import org.gradle.api.logging.LogLevel
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_EXPERIMENTAL_INCREMENTAL_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertNotEquals
|
||||
@@ -263,4 +264,26 @@ class KotlinGradleIT: BaseGradleIT() {
|
||||
assertContains("Connected to daemon")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTypeAliasIncremental() {
|
||||
val project = Project("typeAlias", GRADLE_VERSION)
|
||||
val options = defaultBuildOptions().copy(incremental = true)
|
||||
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
val curryKt = project.projectDir.getFileByName("Curry.kt")
|
||||
val useCurryKt = project.projectDir.getFileByName("UseCurry.kt")
|
||||
|
||||
curryKt.modify {
|
||||
it.replace("class Curry", "internal class Curry")
|
||||
}
|
||||
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(project.relativize(curryKt, useCurryKt))
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1-SNAPSHOT'
|
||||
repositories {
|
||||
maven { url 'file://' + pathToKotlinPlugin }
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
repositories {
|
||||
maven { url 'file://' + pathToKotlinPlugin }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package foo
|
||||
|
||||
class Curry<T, R>(private val f: FN2, private val arg1: T) {
|
||||
typealias FN2 = (T, T) -> R
|
||||
|
||||
operator fun invoke(arg2: T): R =
|
||||
f(arg1, arg2)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
class Dummy
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package foo
|
||||
|
||||
class UseCurry {
|
||||
fun test() {
|
||||
val plus1 = Curry(Plus, 1)
|
||||
|
||||
if (plus1(1) != 2) throw AssertionError()
|
||||
}
|
||||
|
||||
private object Plus : Curry<Int, Int>.FN2 {
|
||||
override fun invoke(p0: Int, p1: Int): Int =
|
||||
p0 + p1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user