Skip to content

Commit

Permalink
Merge pull request #24 from jetbrains-academy/fix-bugs-in-types
Browse files Browse the repository at this point in the history
Add possibleBounds to kotlin types
  • Loading branch information
nbirillo authored Oct 20, 2023
2 parents 1bace41 + 36f323b commit 1ff58e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "org.jetbrains.academy.test.system"
version = "2.0.6"
version = "2.0.7"

allprojects {
apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ fun Array<Method>.findMethod(method: TestMethod, customErrorMessage: String? = n
it.name == method.name
}
}
val returnTypeJava = method.returnTypeJava ?: method.returnType.type
val returnTypeJava = (method.returnTypeJava?.let { listOf(it) } ?: listOfNotNull(method.returnType.type, *method.returnType.possibleBounds.toTypedArray())).map { it.lowercase() }
val filteredByType =
filteredByName.filterByCondition(customErrorMessage ?: "The method ${method.name} should have the return type ${method.returnType.getTypePrettyString()}") {
it.returnType.name.getShortName().lowercase() == returnTypeJava.lowercase()
it.returnType.name.getShortName().lowercase() in returnTypeJava
}
val filteredByArgumentsCount =
filteredByType.filterByCondition(customErrorMessage ?: "The method ${method.name} should have ${method.arguments.size} arguments") { it.parameterCount == method.arguments.size }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ data class TestKotlinType(
val abbreviation: String? = null,
val isNullable: Boolean = false,
val params: List<String> = emptyList(),
val possibleBounds: List<String> = emptyList(),
) {
fun getTypePrettyString() = abbreviation ?: run {
if (params.isNotEmpty()) {
Expand Down

0 comments on commit 1ff58e9

Please sign in to comment.