From b5f94363bd9abaafe80ead5399a3e2806eddc9cf Mon Sep 17 00:00:00 2001 From: Ilya Muradyan Date: Thu, 25 Jun 2020 23:43:19 +0300 Subject: [PATCH] Fix #24 It turned out that the problem is no longer actual. doEval("1") call was deleted, test was added. --- .../kotlin/org/jetbrains/kotlin/jupyter/repl.kt | 5 ----- .../jetbrains/kotlin/jupyter/test/replTests.kt | 14 +++++++++++++- src/test/testData/kernelTestPackage-1.0.jar | Bin 0 -> 938 bytes 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/test/testData/kernelTestPackage-1.0.jar diff --git a/src/main/kotlin/org/jetbrains/kotlin/jupyter/repl.kt b/src/main/kotlin/org/jetbrains/kotlin/jupyter/repl.kt index e55574eb7..76c20a8f1 100644 --- a/src/main/kotlin/org/jetbrains/kotlin/jupyter/repl.kt +++ b/src/main/kotlin/org/jetbrains/kotlin/jupyter/repl.kt @@ -275,11 +275,6 @@ class ReplForJupyterImpl(val scriptClasspath: List = emptyList(), } } - init { - // TODO: to be removed after investigation of https://github.com/kotlin/kotlin-jupyter/issues/24 - doEval("1") - } - private fun executeInitCellCode() = initCellCodes.forEach(::evalNoReturn) private fun executeInitCode(p: PreprocessingResult) = p.initCodes.forEach(::evalNoReturn) diff --git a/src/test/kotlin/org/jetbrains/kotlin/jupyter/test/replTests.kt b/src/test/kotlin/org/jetbrains/kotlin/jupyter/test/replTests.kt index 4c5dc8ed0..07ad128cd 100644 --- a/src/test/kotlin/org/jetbrains/kotlin/jupyter/test/replTests.kt +++ b/src/test/kotlin/org/jetbrains/kotlin/jupyter/test/replTests.kt @@ -65,7 +65,7 @@ class ReplTest { val message = ex.message val expectedLocation = SourceCode.Location(SourceCode.Position(3, 11), SourceCode.Position(3, 14)) - val expectedMessage = "Line_1.jupyter.kts (3:11 - 14) Unresolved reference: ppp" + val expectedMessage = "Line_0.jupyter.kts (3:11 - 14) Unresolved reference: ppp" assertEquals(expectedLocation, location) assertEquals(expectedMessage, message) @@ -110,6 +110,18 @@ class ReplTest { } } + @Test + fun testExternalStaticFunctions() { + val repl = ReplForJupyterImpl(classpath) + val res = repl.eval(""" + @file:DependsOn("src/test/testData/kernelTestPackage-1.0.jar") + import pack.* + func() + """.trimIndent()) + + assertEquals(42, res.resultValue) + } + @Test fun testScriptIsolation() { val repl = ReplForJupyterImpl(classpath) diff --git a/src/test/testData/kernelTestPackage-1.0.jar b/src/test/testData/kernelTestPackage-1.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..4415031e6ebd4368818675c4f1fe28b39754a2e3 GIT binary patch literal 938 zcmWIWW@h1HVBp|jP~UkofB^`YKm-tQ0RF+Ei;JHI3+GcP_jKczG$H8~+6Aq|LIk{I>k^rkf(d6J_T zw*8XLdm%InfM&wI#R_B>08PX2(t#Gnhgysb49!3+08`{vn&(}jmzI+^^eNN{n^wvIUNz&nzTW;a2dwl0f_cOC=mp-jE?0uS}@Tf=hzomX! z=bM$2w#?_sy&AGlWATpawWWEjp*zi99CBRCb3%V>VEggX{+o)|waN=V1)6@B-0M|x zvnb#n)9xI`brHE6N>e$^4`r3stogh7D~I%ro(nDpERtI`9Mx^!b#U9kbMgV+j7%cT zxKkA