Skip to content

Commit 9206e80

Browse files
committed
Refactor verifyStackTrace
It used to wrap the only loop where something happened in two other loops that did nothing. Now, only the innermost loop is left.
1 parent 23ab6ff commit 9206e80

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

kotlinx-coroutines-debug/test/StracktraceUtils.kt

+5-9
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ public fun String.applyBackspace(): String {
3232

3333
public fun verifyStackTrace(e: Throwable, traces: List<String>) {
3434
val stacktrace = toStackTrace(e)
35+
val trimmedStackTrace = stacktrace.trimStackTrace()
3536
traces.forEach {
36-
val expectedLines = it.trimStackTrace().split("\n")
37-
for (i in 0 until expectedLines.size) {
38-
traces.forEach {
39-
assertTrue(
40-
stacktrace.trimStackTrace().contains(it.trimStackTrace()),
41-
"\nExpected trace element:\n$it\n\nActual stacktrace:\n$stacktrace"
42-
)
43-
}
44-
}
37+
assertTrue(
38+
trimmedStackTrace.contains(it.trimStackTrace()),
39+
"\nExpected trace element:\n$it\n\nActual stacktrace:\n$stacktrace"
40+
)
4541
}
4642

4743
val causes = stacktrace.count("Caused by")

0 commit comments

Comments
 (0)