Skip to content

Commit

Permalink
use assertEquals() instead of identity check
Browse files Browse the repository at this point in the history
  • Loading branch information
sockeqwe committed May 5, 2023
1 parent 5f2c5bb commit 433f0dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,4 @@ internal value class CoroutineWaiter(private val job: CompletableJob = Job()) {
internal fun isResumed(): Boolean {
return job.isCompleted
}

/**
* This function is only meant to be used for unit testing purposes.
*
* Returns true if this [CoroutineWaiter] is the same as the [other] [CoroutineWaiter]
* by comparing the identity of the underlying [Job] instance.
*
* The reason why this function exists is because inline value classes do not support identity comparison
* with === operator nor equals() comparison. It is simply not implemented and supported by the kotlin compiler.
*/
internal fun isTheSame(other: CoroutineWaiter): Boolean = job === other.job
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ internal class SubStateMachinesMapTest {
when (i) {
0 -> {
assertSame(s1, sm)
assertTrue(w1.isTheSame(waiter))
assertEquals(w2, waiter)
}

1 -> {
assertSame(s2, sm)
assertTrue(w2.isTheSame(waiter))
assertEquals(w2, waiter)
}
else -> throw Exception("Unexpected loop value $i")
}
Expand Down

0 comments on commit 433f0dd

Please sign in to comment.