From 974fb902ad43f8a454cac48063e507a2aa187db3 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 7 Mar 2025 12:54:06 +0000 Subject: [PATCH] add: runtime test --- .../RuntimeSuggestionUpdatesTest.scala | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala index 7995ddbf36b3..152664325c53 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala @@ -1498,4 +1498,150 @@ class RuntimeSuggestionUpdatesTest } indexedModules should contain theSameElementsAs Seq(moduleName) } + + it should "index local functions (12239)" in { + val contextId = UUID.randomUUID() + val requestId = UUID.randomUUID() + val moduleName = "Enso_Test.Test.Main" + + val contents = + """from Standard.Base.Data.Numbers import Number + |from Standard.Base.Data.Text import Text + | + |some_func x:(Text|Number) = x + 'e' + | + |main = + | any1 = Main.some_func 'y' + | any1 + |""".stripMargin.linesIterator.mkString("\n") + val mainFile = context.writeMain(contents) + + // create context + context.send(Api.Request(requestId, Api.CreateContextRequest(contextId))) + context.receive shouldEqual Some( + Api.Response(requestId, Api.CreateContextResponse(contextId)) + ) + + // open file + context.send( + Api.Request(requestId, Api.OpenFileRequest(mainFile, contents)) + ) + context.receive shouldEqual Some( + Api.Response(Some(requestId), Api.OpenFileResponse) + ) + + // push main + context.send( + Api.Request( + requestId, + Api.PushContextRequest( + contextId, + Api.StackItem.ExplicitCall( + Api.MethodPointer(moduleName, "Enso_Test.Test.Main", "main"), + None, + Vector() + ) + ) + ) + ) + context.receiveNIgnoreExpressionUpdates( + 3 + ) should contain theSameElementsAs Seq( + Api.Response(requestId, Api.PushContextResponse(contextId)), + Api.Response( + Api.SuggestionsDatabaseModuleUpdateNotification( + module = moduleName, + actions = Vector(Api.SuggestionsDatabaseAction.Clean(moduleName)), + exports = Vector( + Api.ExportsUpdate( + ModuleExports( + moduleName, + ListSet( + ExportedSymbol.Method(moduleName, "main"), + ExportedSymbol.Method(moduleName, "some_func") + ) + ), + Api.ExportsAction.Add() + ) + ), + updates = Tree.Root( + Vector( + Tree.Node( + Api.SuggestionUpdate( + Suggestion.Module( + moduleName, + None + ), + Api.SuggestionAction.Add() + ), + Vector() + ), + Tree.Node( + Api.SuggestionUpdate( + Suggestion.DefinedMethod( + None, + moduleName, + "some_func", + Seq( + Suggestion + .Argument( + "x", + "Standard.Base.Data.Text.Text | Standard.Base.Data.Numbers.Number", + false, + false, + None + ) + ), + moduleName, + ConstantsGen.ANY, + true, + None, + Seq() + ), + Api.SuggestionAction.Add() + ), + Vector() + ), + Tree.Node( + Api.SuggestionUpdate( + Suggestion.DefinedMethod( + None, + moduleName, + "main", + Seq(), + moduleName, + ConstantsGen.ANY, + true, + None, + Seq() + ), + Api.SuggestionAction.Add() + ), + Vector( + Tree.Node( + Api.SuggestionUpdate( + Suggestion.Local( + None, + moduleName, + "any1", + ConstantsGen.ANY, + Suggestion.Scope( + Suggestion.Position(5, 6), + Suggestion.Position(7, 8) + ), + None + ), + Api.SuggestionAction.Add() + ), + Vector() + ) + ) + ) + ) + ) + ) + ), + context.executionComplete(contextId) + ) + } }