IR Scripting: update capturing logic for the REPL, imported scripts,

as well as all other implicit receivers.
This commit is contained in:
Ilya Chernikov
2022-03-22 19:02:35 +01:00
committed by teamcity
parent 4ec639cafd
commit 35f80c04ca
8 changed files with 223 additions and 43 deletions
@@ -67,6 +67,30 @@ class ReplTest : TestCase() {
Assert.assertEquals("x = 3", out)
}
@Test
fun testCaptureFromPreviousSnippets() {
val out = captureOut {
checkEvaluateInRepl(
sequenceOf(
"val x = 3",
"fun b() = x",
"b()",
"println(\"b() = \${b()}\")",
"val y = x + 2",
"y",
"class Nested { fun c() = x + 4 }",
"Nested().c()",
"inner class Inner { fun d() = x + 6 }",
"Inner().d()",
"class TwoLevel { inner class Inner { fun e() = x + 8 } }",
"TwoLevel().Inner().e()",
),
sequenceOf(null, null, 3, null, null, 5, null, 7, null, 9, null, 11)
)
}
Assert.assertEquals("b() = 3", out)
}
@Test
fun testEvalWithResult() {
checkEvaluateInRepl(