Skip to content

Commit 2969654

Browse files
committed
Fix #84
1 parent 60300c7 commit 2969654

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/kotlin/org/jetbrains/kotlin/jupyter/connection.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class JupyterConnection(val config: KernelConfig): Closeable {
9595
currentBuf = null
9696
return -1
9797
}
98-
currentBufPos.inc()
99-
return buf[currentBufPos - 1].toInt()
98+
99+
return buf[currentBufPos++].toInt()
100100
}
101101

102102
@Synchronized

src/test/kotlin/org/jetbrains/kotlin/jupyter/test/executeTests.kt

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.jetbrains.kotlin.jupyter.*
55
import org.junit.Assert
66
import org.junit.Test
77
import org.zeromq.ZMQ
8+
import kotlin.test.assertEquals
89

910
fun Message.type(): String {
1011
return header!!["msg_type"] as String
@@ -132,4 +133,14 @@ class ExecuteTests : KernelServerTestsBase() {
132133
val res = doExecute(code, false, ::checker)
133134
Assert.assertNull(res)
134135
}
136+
137+
@Test
138+
fun testReadLine() {
139+
val code = """
140+
val answer = readLine()
141+
answer
142+
""".trimIndent()
143+
val res = doExecute(code, inputs = listOf("42"))
144+
assertEquals(jsonObject("text/plain" to "42"), res)
145+
}
135146
}

0 commit comments

Comments
 (0)