Skip to content

Commit 62d6702

Browse files
committed
Fix the test
1 parent a517a6f commit 62d6702

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

.vscode/launch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
"name": "Debug KotlinDebugAdapter",
1515
"projectRoot": "${workspaceFolder}/adapter",
1616
"mainClass": "org.javacs.ktda.KDAMainKt"
17+
},
18+
{
19+
"type": "kotlin",
20+
"request": "launch",
21+
"name": "Debug Sample Workspace",
22+
"projectRoot": "${workspaceFolder}/adapter/src/test/resources/sample-workspace",
23+
"mainClass": "sample.workspace.AppKt"
1724
}
1825
]
1926
}

adapter/src/test/kotlin/org/javacs/ktda/SampleWorkspaceTest.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import org.eclipse.lsp4j.debug.StoppedEventArguments
1010
import org.eclipse.lsp4j.debug.VariablesArguments
1111
import org.junit.Assert.assertThat
1212
import org.junit.Test
13-
import org.hamcrest.Matchers.contains
13+
import org.hamcrest.Matchers.containsInAnyOrder
1414
import org.hamcrest.Matchers.equalTo
15+
import org.hamcrest.Matchers.hasItem
1516
import org.hamcrest.Matchers.nullValue
1617
import org.hamcrest.Matchers.not
1718
import java.util.concurrent.Semaphore
@@ -55,24 +56,25 @@ class SampleWorkspaceTest : DebugAdapterTestFixture("sample-workspace", "sample.
5556
val stackTrace = debugAdapter.stackTrace(StackTraceArguments().apply {
5657
threadId = args.threadId
5758
}).join()
58-
val topFrame = stackTrace.stackFrames.first()
59-
val scopes = debugAdapter.scopes(ScopesArguments().apply {
60-
frameId = topFrame.id
61-
}).join()
62-
val scope = scopes.scopes.first()
63-
val variables = debugAdapter.variables(VariablesArguments().apply {
64-
variablesReference = scope.variablesReference
65-
}).join()
66-
val receiver = variables.variables.find { it.name == "this" }
59+
val locals = stackTrace.stackFrames.asSequence().flatMap {
60+
debugAdapter.scopes(ScopesArguments().apply {
61+
frameId = it.id
62+
}).join().scopes.asSequence().flatMap {
63+
debugAdapter.variables(VariablesArguments().apply {
64+
variablesReference = it.variablesReference
65+
}).join().variables.asSequence()
66+
}
67+
}.toList()
68+
val receiver = locals.find { it.name == "this" }
6769

68-
assertThat(variables.variables.map { Pair(it.name, it.value) }, contains(Pair("local", "123")))
70+
assertThat(locals.map { Pair(it.name, it.value) }, hasItem(Pair("local", "123")))
6971
assertThat(receiver, not(nullValue()))
7072

7173
val members = debugAdapter.variables(VariablesArguments().apply {
7274
variablesReference = receiver!!.variablesReference
73-
}).join()
75+
}).join().variables
7476

75-
assertThat(members.variables.map { Pair(it.name, it.value) }, contains(Pair("member", "test")))
77+
assertThat(members.map { Pair(it.name, it.value) }, containsInAnyOrder(Pair("member", "\"test\"")))
7678
} catch (e: Throwable) {
7779
asyncException = e
7880
} finally {

0 commit comments

Comments
 (0)