Skip to content

Commit

Permalink
Use kotlin when
Browse files Browse the repository at this point in the history
  • Loading branch information
rogervinas committed Sep 14, 2022
1 parent 55c026e commit 705d792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions mutation-testing/src/main/kotlin/org/testingplayground/MyImpl.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package org.testingplayground

class MyImpl {
fun doSomething(a: Int, b: Int): String {
if (a < 0 || b < 0) {
return "Either A or B are negative"
}
if (a == 0 && b == 0) {
return "Both A and B are zero"
}
if (a > b) {
return "A is greater than B"
}
return if (b > a) {
"B is greater than A"
} else "A and B are equal"
fun doSomething(a: Int, b: Int) = when {
(a < 0 || b < 0) -> "Either A or B are negative"
(a == 0 && b == 0) -> "Both A and B are zero"
(a > b) -> "A is greater than B"
(b > a) -> "B is greater than A"
else -> "A and B are equal"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class MyImplTest {
//
// The quality of your tests can be gauged from the percentage of mutations killed.

// ./gradlew mutation-testing:clean mutation-testing:test mutation-testing:pitest
// ./gradlew -p mutation-testing clean test pitest

private val myImpl = MyImpl()

Expand Down

0 comments on commit 705d792

Please sign in to comment.