Skip to content

Commit

Permalink
add: runtime test
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed Mar 7, 2025
1 parent a526b2b commit 974fb90
Showing 1 changed file with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
}
}

0 comments on commit 974fb90

Please sign in to comment.