-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(compiler-plugin-test): migrate a couple of tests to kotlin.test
also makes the project compatible with Kotest 6.0.0.M2
- Loading branch information
Showing
10 changed files
with
177 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...ugin-test/src/test/kotlin/it/unibo/collektive/test/IterationUsingDelegatesWithoutAlign.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2024, Danilo Pianini, Nicolas Farabegoli, Elisa Tronetti, | ||
* and all authors listed in the `build.gradle.kts` and the generated `pom.xml` file. | ||
* | ||
* This file is part of Collektive, and is distributed under the terms of the Apache License 2.0, | ||
* as described in the LICENSE file in this project's repository's top directory. | ||
*/ | ||
|
||
package it.unibo.collektive.test | ||
|
||
import io.github.subjekt.Subjekt.subjekt | ||
import io.github.subjekt.generators.FilesGenerator.toTempFiles | ||
import it.unibo.collektive.test.util.CompileUtils.formsOfIteration | ||
import it.unibo.collektive.test.util.CompileUtils.`iteration with warning` | ||
import it.unibo.collektive.test.util.CompileUtils.`iteration without warning` | ||
import it.unibo.collektive.test.util.CompileUtils.testedAggregateFunctions | ||
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
import java.io.File | ||
import kotlin.test.Test | ||
|
||
@OptIn(ExperimentalCompilerApi::class) | ||
class IterationUsingDelegatesWithoutAlign { | ||
private val testSubjects: Map<String, File> = | ||
subjekt { | ||
addSource("src/test/resources/subjekt/IterationWithDelegatedAggregate.yaml") | ||
}.toTempFiles() | ||
|
||
@Test | ||
fun `test iterations using delegates`() { | ||
for (functionCall in testedAggregateFunctions) { | ||
val functionName = functionCall.substringBefore("(") | ||
for ((iteration, _) in formsOfIteration) { | ||
with(testSubjects) { | ||
`iteration with warning`("IterationDelegate", functionName, iteration, expectedWarning) | ||
`iteration without warning`("IterationAlignDelegate", functionName, iteration) | ||
`iteration without warning`("IterationDelegateAlign", functionName, iteration) | ||
`iteration without warning`("IterationDelegateWithNestedFun", functionName, iteration) | ||
`iteration with warning`("IterationRecursiveDelegate", functionName, iteration, expectedWarning) | ||
`iteration without warning`("IterationAlignRecursiveDelegate", functionName, iteration) | ||
`iteration without warning`("IterationRecursiveDelegateAlign", functionName, iteration) | ||
// Disabled tests | ||
// `iteration with warning`("IterationDelegatedNestedFun", functionName, iteration, expectedWarning) | ||
// `iteration without warning`("IterationAlignDelegatedNestedFun", functionName, iteration) | ||
// `iteration without warning`("IterationDelegatedNestedFunAlign", functionName, iteration) | ||
} | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val expectedWarning: String = | ||
""" | ||
Function 'delegate', that accepts and uses an aggregate argument, has been called inside a loop construct | ||
without explicit alignment. | ||
The same path may generate interactions more than once, leading to ambiguous alignment. | ||
Consider to wrap the function into the 'alignedOn' method with a unique element, either at the call site | ||
or inside the 'delegate' function declaration, wrapping the involved aggregate calls. | ||
""".trimIndent() | ||
} | ||
} |
166 changes: 0 additions & 166 deletions
166
...-test/src/test/kotlin/it/unibo/collektive/test/IterationUsingDelegatesWithoutAlignSpec.kt
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
compiler-plugin-test/src/test/kotlin/it/unibo/collektive/test/IterationWithoutAlign.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package it.unibo.collektive.test | ||
|
||
import io.github.subjekt.Subjekt.subjekt | ||
import io.github.subjekt.generators.FilesGenerator.toTempFiles | ||
import it.unibo.collektive.test.util.CompileUtils.formsOfIteration | ||
import it.unibo.collektive.test.util.CompileUtils.`iteration with warning` | ||
import it.unibo.collektive.test.util.CompileUtils.`iteration without warning` | ||
import it.unibo.collektive.test.util.CompileUtils.testedAggregateFunctions | ||
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi | ||
import kotlin.test.Test | ||
|
||
@OptIn(ExperimentalCompilerApi::class) | ||
class IterationWithoutAlign { | ||
private val testSubjects = | ||
subjekt { | ||
addSource("src/test/resources/subjekt/IterationWithAggregate.yaml") | ||
}.toTempFiles() | ||
|
||
@Test | ||
fun `test iterations without align`() { | ||
for (functionCall in testedAggregateFunctions) { | ||
val functionName = functionCall.substringBefore("(") | ||
for ((iteration, _) in formsOfIteration) { | ||
with(testSubjects) { | ||
`iteration with warning`("Iteration", functionName, iteration, expectedWarn(functionName)) | ||
`iteration without warning`("IterationAlign", functionName, iteration) | ||
`iteration with warning`("IterationExtAlign", functionName, iteration, expectedWarn(functionName)) | ||
`iteration without warning`("IterationWithNestedFun", functionName, iteration) | ||
`iteration without warning`("OutsideAggregate", functionName, iteration) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private companion object { | ||
private fun expectedWarn(functionName: String): String = | ||
""" | ||
Aggregate function '$functionName' has been called inside a loop construct without explicit alignment. | ||
The same path may generate interactions more than once, leading to ambiguous alignment. | ||
Consider to wrap the function into the 'alignedOn' method with a unique element. | ||
""".trimIndent() | ||
} | ||
} |
Oops, something went wrong.