Skip to content

Commit

Permalink
Fix a small bug with findMethod function
Browse files Browse the repository at this point in the history
  • Loading branch information
nbirillo committed Sep 8, 2023
1 parent 3558036 commit a40cb30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 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.5"
version = "2.0.6"

allprojects {
apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ fun Array<Method>.findMethod(method: TestMethod, customErrorMessage: String? = n
}
val filteredByArgumentsCount =
filteredByType.filterByCondition(customErrorMessage ?: "The method ${method.name} should have ${method.arguments.size} arguments") { it.parameterCount == method.arguments.size }
require(filteredByArgumentsCount.size == 1) { customErrorMessage ?: "The method ${method.prettyString()} is missed. Check it's arguments properly." }
val m = filteredByArgumentsCount.first()
val params = m.parameterTypes.map { it.name.getShortName().lowercase() }
val args = method.arguments.map { it.javaType.lowercase() }
assert(params == args) { customErrorMessage ?: "The method ${method.name} should have ${method.arguments.size} arguments: $params. The full signature is: ${method.prettyString()}." }
return m
val methods = filteredByArgumentsCount.filterByCondition(customErrorMessage ?: "The method ${method.prettyString()} is missed. Check it's arguments properly." ) { m -> m.parameterTypes.map { it.name.getShortName().lowercase() } == args }
require(methods.size == 1) { customErrorMessage ?: "The method ${method.name} should have ${method.arguments.size} arguments: $args. The full signature is: ${method.prettyString()}." }
return methods.first()
}

0 comments on commit a40cb30

Please sign in to comment.