@@ -10,6 +10,7 @@ import org.jetbrains.kotlinx.jupyter.generateDiagnostic
10
10
import org.jetbrains.kotlinx.jupyter.generateDiagnosticFromAbsolute
11
11
import org.jetbrains.kotlinx.jupyter.repl.CompletionResult
12
12
import org.jetbrains.kotlinx.jupyter.repl.ListErrorsResult
13
+ import org.jetbrains.kotlinx.jupyter.test.getOrFail
13
14
import org.jetbrains.kotlinx.jupyter.withPath
14
15
import org.junit.jupiter.api.Assertions.assertTrue
15
16
import org.junit.jupiter.api.Test
@@ -163,12 +164,7 @@ class ReplTests : AbstractSingleReplTest() {
163
164
164
165
runBlocking {
165
166
repl.complete(" val t = foo" , 11 ) {
166
- result ->
167
- if (result is CompletionResult .Success ) {
168
- assertEquals(arrayListOf (" foobar" , " foobaz" ), result.sortedMatches())
169
- } else {
170
- fail(" Result should be success" )
171
- }
167
+ assertEquals(arrayListOf (" foobar" , " foobaz" ), it.getOrFail().sortedMatches())
172
168
}
173
169
}
174
170
}
@@ -177,12 +173,7 @@ class ReplTests : AbstractSingleReplTest() {
177
173
fun testNoCompletionAfterNumbers () {
178
174
runBlocking {
179
175
repl.complete(" val t = 42" , 10 ) {
180
- result ->
181
- if (result is CompletionResult .Success ) {
182
- assertEquals(emptyList(), result.sortedMatches())
183
- } else {
184
- fail(" Result should be success" )
185
- }
176
+ assertEquals(emptyList(), it.getOrFail().sortedMatches())
186
177
}
187
178
}
188
179
}
@@ -206,11 +197,41 @@ class ReplTests : AbstractSingleReplTest() {
206
197
)
207
198
runBlocking {
208
199
repl.complete(" df.filter { c_ }" , 14 ) { result ->
209
- if (result is CompletionResult .Success ) {
210
- assertEquals(arrayListOf (" c_meth_z(" , " c_prop_x" , " c_prop_y" , " c_zzz" ), result.sortedMatches())
211
- } else {
212
- fail(" Result should be success" )
213
- }
200
+ assertEquals(
201
+ arrayListOf (" c_meth_z(" , " c_prop_x" , " c_prop_y" , " c_zzz" ),
202
+ result.getOrFail().sortedMatches()
203
+ )
204
+ }
205
+ }
206
+ }
207
+
208
+ @Test
209
+ fun testParametersCompletion () {
210
+ eval(" fun f(xyz: Int) = xyz * 2" )
211
+
212
+ runBlocking {
213
+ repl.complete(" val t = f(x" , 11 ) {
214
+ assertEquals(arrayListOf (" xyz = " ), it.getOrFail().sortedMatches())
215
+ }
216
+ }
217
+ }
218
+
219
+ @Test
220
+ fun testDeprecationCompletion () {
221
+ eval(
222
+ """
223
+ @Deprecated("use id() function instead")
224
+ fun id_deprecated(x: Int) = x
225
+ """ .trimIndent()
226
+ )
227
+
228
+ runBlocking {
229
+ repl.complete(" val t = id_d" , 12 ) { result ->
230
+ assertTrue(
231
+ result.getOrFail().sortedRaw().any {
232
+ it.text == " id_deprecated(" && it.deprecationLevel == DeprecationLevel .WARNING
233
+ }
234
+ )
214
235
}
215
236
}
216
237
}
0 commit comments