Merging from development

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-12-07 12:35:41 -08:00
parent b1eeebb6b6
commit cd5306febf
334 changed files with 9946 additions and 3757 deletions
@@ -25,126 +25,6 @@ using namespace ScriptCanvasTests;
using namespace TestNodes;
using namespace ScriptCanvas::Execution;
// TODO: This fails to compile on Linux only
//ScriptCanvas::Grammar::SubgraphInterface* CreateExecutionMap(AZ::BehaviorContext& behaviorContext)
//{
// using namespace ScriptCanvas;
// using namespace ScriptCanvas::Grammar;
//
// auto ins = CreateInsFromBehaviorContextMethods("TestNodeableObject", behaviorContext, { "Branch" } );
// auto branchOutVoidTrue = CreateOut<Data::BooleanType, const Data::StringType&>("BranchTrue", { "condition", "message" });
// auto branchOutVoidFalse = CreateOut<Data::BooleanType, const Data::StringType&, const Data::Vector3Type&>("BranchFalse", { "condition", "message", "vector" });
//
// auto branchOut = FindInByName("Branch", ins);
//
// EXPECT_NE(branchOut, nullptr);
// if (branchOut)
// {
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidTrue));
// branchOut->outs.emplace_back(AZStd::move(branchOutVoidFalse));
// }
//
// return aznew SubgraphInterface(AZStd::move(ins));
//}
TEST_F(ScriptCanvasTestFixture, TestLuaObjectOrientation)
{
using namespace ScriptCanvas;
using namespace ScriptCanvas::Grammar;
AZ::ScriptContext sc;
sc.BindTo(m_behaviorContext);
RegisterAPI(sc.NativeContext());
EXPECT_TRUE(sc.Execute(
R"LUA(
assert(Nodeable ~= nil, 'Nodeable was nill')
assert(Nodeable.__call ~= nil, 'Nodeable.__call was nil')
assert(type(Nodeable.__call) == 'function', 'Nodeable.__call was not a function')
local nodeable = Nodeable()
assert(nodeable ~= nil, 'nodeable was nil')
assert(type(nodeable) == "userdata", 'nodeable not userdata')
local SubGraph = {}
SubGraph.s_name = "SubGraphery"
SubGraph.s_createdCount = 0
function SubGraph:IncrementCreated()
SubGraph.s_createdCount = 1 + SubGraph.s_createdCount
end
setmetatable(SubGraph, { __index = Nodeable }) -- exposed through BehaviorContext
local SubGraphInstanceMetatable = { __index = SubGraph }
assert(getmetatable(SubGraph).__index == Nodeable, 'getmetatable(SubGraph).__index = Nodeable')
assert(type(getmetatable(SubGraph).__index) == 'table', "type(getmetatable(SubGraph).__index) ~= 'table'")
function SubGraph.new() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = OverrideNodeableMetatable(Nodeable(), SubGraphInstanceMetatable)
assert(type(instance.s_createdCount) == 'number', 'subgraph.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph.newTable() -- Add executionState input here and to Nodeable()
-- now individual instance values can be initialized
local instance = setmetatable({}, SubGraphInstanceMetatable)
-- assert(getmetatable(instance) == SubGraphInstanceMetatable, "subgraphT")
assert(type(instance.s_createdCount) == 'number', 'subgraphT.s_createdCount was not a number')
instance:IncrementCreated()
instance.name = 'SubGraph '..tostring(instance.s_createdCount)
return instance
end
function SubGraph:Foo()
return "I, " .. tostring(self.name) .. ", am a user function"
end
local subgraphT = SubGraph.newTable()
assert(subgraphT ~= nil, "subgraphT was nil")
assert(type(subgraphT) == 'table', 'subgraphT was not a table')
assert(type(subgraphT.IsActive)== 'function', "subgraphT IsActive was not a function")
assert(type(subgraphT.Foo) == 'function', 'subgraphT was not a function')
local subgraphTResult = subgraphT:Foo()
assert(subgraphTResult == "I, SubGraph 1, am a user function", 'subgraphT did not return the right results:' .. tostring(subgraphTResult))
assert(subgraphT.s_createdCount == 1, "subgraphT created count was not one: ".. tostring(subgraphT.s_createdCount))
subgraphT = SubGraph.newTable()
assert(subgraphT.s_createdCount == 2, "subgraphT created count was not two: ".. tostring(subgraphT.s_createdCount))
local subgraph = SubGraph.new()
assert(subgraph ~= nil, "subgraph was nil")
assert(type(subgraph) == 'userdata', 'was not userdata')
assert(type(subgraph.IsActive)== 'function', "IsActive was not a function")
assert(not subgraph.IsActive(subgraph), "did not inherit properly")
assert(not subgraph:IsActive(), "did not inherit properly")
assert(type(subgraph.Foo) == 'function', 'was not a function')
local subgraphResult = subgraph:Foo()
assert(subgraphResult == "I, SubGraph 3, am a user function", 'subgraph:Foo() did not return the right results: ' .. tostring(subgraphResult))
assert(subgraph.s_createdCount == 3, "created count was not three: "..tostring(subgraph.s_createdCount))
local subgraph2 = SubGraph.new()
assert(subgraph2 ~= nil, "subgraph2 was nil")
assert(type(subgraph2) == 'userdata', 'subgraph2 was not userdata')
assert(type(subgraph2.IsActive)== 'function', "subgraph2 IsActive was not a function")
assert(not subgraph2.IsActive(subgraph2), "subgraph2 did not inherit properly")
assert(not subgraph2:IsActive(), "subgraph2 did not inherit properly")
assert(type(subgraph2.Foo) == 'function', 'subgraph2 was not a function')
local subgraph2Result = subgraph2:Foo()
assert(subgraph2Result == "I, SubGraph 4, am a user function", 'subgraph2:Foo() did not return the right results: ' .. tostring(subgraph2Result))
assert(subgraph2.s_createdCount == 4, "created count was not three: "..tostring(subgraph2.s_createdCount))
return SubGraph
)LUA"
));
}
//
// TEST_F(ScriptCanvasTestFixture, NativeNodeableStack)
// {
// TestNodeableObject nodeable;