1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Backward compatibility.

This commit is contained in:
Cedric Beust 2017-03-25 13:09:20 -07:00
parent 86c166ff76
commit 6974e6cdb2
2 changed files with 31 additions and 6 deletions

View file

@ -16,7 +16,7 @@ import java.util.*
@Guice(modules = arrayOf(TestModule::class))
class ProfileTest @Inject constructor(compilerFactory: BuildFileCompiler.IFactory) : BaseTest(compilerFactory) {
private fun runTestWithProfile(enabled: Boolean) : Project {
private fun runTestWithProfile(enabled: Boolean, oldSyntax: Boolean) : Project {
val projectVal = "p" + Math.abs(Random().nextInt())
val projectDirectory = createTemporaryProjectDirectory()
@ -24,7 +24,9 @@ class ProfileTest @Inject constructor(compilerFactory: BuildFileCompiler.IFactor
return """
import com.beust.kobalt.*
import com.beust.kobalt.api.*
val profile by profile()
val profile""" +
(if (oldSyntax) " = false\n" else " by profile()\n") +
"""
val $projectVal = project {
name = if (profile) "profileOn" else "profileOff"
directory = "$projectDirectory"
@ -46,7 +48,13 @@ class ProfileTest @Inject constructor(compilerFactory: BuildFileCompiler.IFactor
@Test(dataProvider = "dp")
fun profilesShouldWork(enabled: Boolean, expected: String) {
Kobalt.init(TestModule())
assertThat(runTestWithProfile(enabled).name).isEqualTo(expected)
assertThat(runTestWithProfile(enabled, oldSyntax = false).name).isEqualTo(expected)
}
@Test(dataProvider = "dp")
fun profilesShouldWorkOldSyntax(enabled: Boolean, expected: String) {
Kobalt.init(TestModule())
assertThat(runTestWithProfile(enabled, oldSyntax = true).name).isEqualTo(expected)
}
}