Skip to content

Commit

Permalink
Bringing in Dmitry's test
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Mar 20, 2024
1 parent 5a3bc11 commit f64210a
Showing 1 changed file with 176 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,90 @@ class RuntimeServerTest
)
}

it should "send method pointer updates of autoscope constructors" in {
val contextId = UUID.randomUUID()
val requestId = UUID.randomUUID()
val moduleName = "Enso_Test.Test.Main"

val metadata = new Metadata
val idA = metadata.addItem(52, 3, "aa")
val idB = metadata.addItem(70, 6, "ab")
val idC = metadata.addItem(88, 7, "ac")

val code =
"""type T
| A
| B x
| C y z
|
|main =
| a = test ..A
| b = test (..B 42)
| test (..C a b)
|
|test t:T = t
|""".stripMargin.linesIterator.mkString("\n")
val contents = metadata.appendToCode(code)
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, moduleName, "main"),
None,
Vector()
)
)
)
)
context.receiveN(5) should contain theSameElementsAs Seq(
Api.Response(requestId, Api.PushContextResponse(contextId)),
TestMessages.update(
contextId,
idA,
"Enso_Test.Test.Main.T",
Api.MethodCall(
Api.MethodPointer("Enso_Test.Test.Main", "Enso_Test.Test.Main.T", "A")
)
),
TestMessages.update(
contextId,
idB,
"Enso_Test.Test.Main.T",
Api.MethodCall(
Api.MethodPointer("Enso_Test.Test.Main", "Enso_Test.Test.Main.T", "B")
)
),
TestMessages.update(
contextId,
idC,
"Enso_Test.Test.Main.T",
Api.MethodCall(
Api.MethodPointer("Enso_Test.Test.Main", "Enso_Test.Test.Main.T", "C")
)
),
context.executionComplete(contextId)
)
}

it should "send method pointer updates of builtin operators" in {
val contextId = UUID.randomUUID()
val requestId = UUID.randomUUID()
Expand Down Expand Up @@ -1081,6 +1165,98 @@ class RuntimeServerTest
)
}

it should "send method pointer updates of partially applied autoscope constructors" in {
val contextId = UUID.randomUUID()
val requestId = UUID.randomUUID()
val moduleName = "Enso_Test.Test.Main"

val metadata = new Metadata
val id_x_0 = metadata.addItem(40, 3, "aa")
val id_x_1 = metadata.addItem(60, 5, "ab")

val code =
"""type T
| A x y
|
|main =
| x_0 = test ..A
| x_1 = test (..A 1)
| T.A x_0 x_1
|
|test t:T = t
|""".stripMargin.linesIterator.mkString("\n")
val contents = metadata.appendToCode(code)
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, moduleName, "main"),
None,
Vector()
)
)
)
)
context.receiveN(4) should contain theSameElementsAs Seq(
Api.Response(requestId, Api.PushContextResponse(contextId)),
TestMessages.update(
contextId,
id_x_0,
ConstantsGen.FUNCTION_BUILTIN,
methodCall = Some(
Api.MethodCall(Api.MethodPointer(moduleName, s"$moduleName.T", "A"))
),
payload = Api.ExpressionUpdate.Payload.Value(
functionSchema = Some(
Api.FunctionSchema(
Api.MethodPointer(moduleName, s"$moduleName.T", "A"),
Vector(0, 1)
)
)
)
),
TestMessages.update(
contextId,
id_x_1,
ConstantsGen.FUNCTION_BUILTIN,
methodCall = Some(
Api.MethodCall(
Api.MethodPointer(moduleName, s"$moduleName.T", "A"),
Vector(1)
)
),
payload = Api.ExpressionUpdate.Payload.Value(
functionSchema = Some(
Api.FunctionSchema(
Api.MethodPointer(moduleName, s"$moduleName.T", "A"),
Vector(1)
)
)
)
),
context.executionComplete(contextId)
)
}

it should "send method pointer updates of partially applied static method returning a method" in {
val contextId = UUID.randomUUID()
val requestId = UUID.randomUUID()
Expand Down

0 comments on commit f64210a

Please sign in to comment.