(49.2%, FAILING) Move groups stuff into its own test for now.
parent
88ace0db19
commit
eba61d34f8
|
@ -0,0 +1,92 @@
|
|||
defmodule FarmbotCeleryScript.CompilerGroupsTest do
|
||||
use ExUnit.Case, async: true
|
||||
alias FarmbotCeleryScript.AST
|
||||
alias Farmbot.TestSupport.CeleryScript.TestSysCalls
|
||||
# alias FarmbotCeleryScript.Compiler
|
||||
# # Only required to compile
|
||||
# alias FarmbotCeleryScript.SysCalls, warn: false
|
||||
# alias FarmbotCeleryScript.Compiler.IdentifierSanitizer
|
||||
|
||||
setup do
|
||||
{:ok, shim} = TestSysCalls.checkout()
|
||||
|
||||
[shim: shim]
|
||||
end
|
||||
|
||||
test "compilation of point_group in parameter application", %{shim: shim} do
|
||||
main = %AST{
|
||||
args: %{
|
||||
locals: %AST{
|
||||
args: %{},
|
||||
body: [
|
||||
%AST{
|
||||
args: %{
|
||||
default_value: %AST{
|
||||
args: %{pointer_id: 1670, pointer_type: "Plant"},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :point,
|
||||
meta: nil
|
||||
},
|
||||
label: "parent"
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :parameter_declaration,
|
||||
meta: nil
|
||||
},
|
||||
%AST{
|
||||
args: %{
|
||||
data_value: %AST{
|
||||
args: %{point_group_id: 34},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :point_group,
|
||||
meta: nil
|
||||
},
|
||||
label: "parent"
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :parameter_application,
|
||||
meta: nil
|
||||
}
|
||||
],
|
||||
comment: nil,
|
||||
kind: :scope_declaration,
|
||||
meta: nil
|
||||
},
|
||||
sequence_name: "Pogo",
|
||||
version: 20_180_209
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :sequence,
|
||||
meta: %{sequence_name: "Pogo"}
|
||||
}
|
||||
|
||||
pid = self()
|
||||
|
||||
:ok =
|
||||
TestSysCalls.handle(shim, fn kind, args ->
|
||||
case kind do
|
||||
:get_point_group ->
|
||||
send(pid, {kind, args})
|
||||
%{name: "woosh", point_ids: [4, 5, 6]}
|
||||
|
||||
:step_complete ->
|
||||
send(pid, {kind, args})
|
||||
{:NOOO}
|
||||
|
||||
:point ->
|
||||
IO.puts("============== NoOoOoOooooo: " <> inspect(kind))
|
||||
%{hmm: args}
|
||||
end
|
||||
end)
|
||||
|
||||
result = FarmbotCeleryScript.Compiler.Sequence.sequence(main, [])
|
||||
IO.inspect(result)
|
||||
IO.puts("Now what!?")
|
||||
assert result
|
||||
end
|
||||
end
|
|
@ -4,7 +4,6 @@ defmodule FarmbotCeleryScript.CompilerTest do
|
|||
# Only required to compile
|
||||
alias FarmbotCeleryScript.SysCalls, warn: false
|
||||
alias FarmbotCeleryScript.Compiler.IdentifierSanitizer
|
||||
alias Farmbot.TestSupport.CeleryScript.TestSysCalls
|
||||
|
||||
test "compiles a sequence with unbound variables" do
|
||||
sequence = %AST{
|
||||
|
@ -52,7 +51,8 @@ defmodule FarmbotCeleryScript.CompilerTest do
|
|||
}
|
||||
]
|
||||
|
||||
compiled_celery_env = Compiler.Utils.compile_params_to_function_args(celery_env, [])
|
||||
compiled_celery_env =
|
||||
Compiler.Utils.compile_params_to_function_args(celery_env, [])
|
||||
|
||||
[body_item] = Compiler.compile(sequence, compiled_celery_env)
|
||||
assert body_item.() == 600
|
||||
|
@ -355,71 +355,6 @@ defmodule FarmbotCeleryScript.CompilerTest do
|
|||
""")
|
||||
end
|
||||
|
||||
test "wow" do
|
||||
main = %FarmbotCeleryScript.AST{
|
||||
args: %{
|
||||
locals: %FarmbotCeleryScript.AST{
|
||||
args: %{},
|
||||
body: [
|
||||
%FarmbotCeleryScript.AST{
|
||||
args: %{
|
||||
default_value: %FarmbotCeleryScript.AST{
|
||||
args: %{pointer_id: 1670, pointer_type: "Plant"},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :point,
|
||||
meta: nil
|
||||
},
|
||||
label: "parent"
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :parameter_declaration,
|
||||
meta: nil
|
||||
},
|
||||
%FarmbotCeleryScript.AST{
|
||||
args: %{
|
||||
data_value: %FarmbotCeleryScript.AST{
|
||||
args: %{point_group_id: 34},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :point_group,
|
||||
meta: nil
|
||||
},
|
||||
label: "parent"
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :parameter_application,
|
||||
meta: nil
|
||||
}
|
||||
],
|
||||
comment: nil,
|
||||
kind: :scope_declaration,
|
||||
meta: nil
|
||||
},
|
||||
sequence_name: "Pogo",
|
||||
version: 20_180_209
|
||||
},
|
||||
body: [],
|
||||
comment: nil,
|
||||
kind: :sequence,
|
||||
meta: %{sequence_name: "Pogo"}
|
||||
}
|
||||
|
||||
pid = self()
|
||||
{:ok, shim} = TestSysCalls.checkout()
|
||||
|
||||
:ok =
|
||||
TestSysCalls.handle(shim, fn :get_point_group = kind, args ->
|
||||
send(pid, {kind, args})
|
||||
%{point_ids: []}
|
||||
end)
|
||||
|
||||
result = FarmbotCeleryScript.Compiler.Sequence.sequence(main, [])
|
||||
assert :ok == result
|
||||
end
|
||||
|
||||
defp compile(ast) do
|
||||
ast
|
||||
|> Compiler.compile_ast([])
|
||||
|
|
Loading…
Reference in New Issue