Skip to content

Commit

Permalink
Add test case of nested types in scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
mafiesto4 committed May 15, 2024
1 parent 17d1d87 commit 35ddfc2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Engine/Tests/TestScripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
#include "Engine/Scripting/ManagedCLR/MUtils.h"
#include <ThirdParty/catch2/catch.hpp>

TestNesting::TestNesting(const SpawnParams& params)
: SerializableScriptingObject(params)
{
}

TestNesting2::TestNesting2(const SpawnParams& params)
: SerializableScriptingObject(params)
{
}

TestClassNative::TestClassNative(const SpawnParams& params)
: ScriptingObject(params)
{
Expand Down
53 changes: 53 additions & 0 deletions Source/Engine/Tests/TestScripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,59 @@
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Engine/Scripting/SerializableScriptingObject.h"

// Test compilation with nested types.
API_CLASS() class TestNesting : public SerializableScriptingObject
{
DECLARE_SCRIPTING_TYPE(TestNesting);
API_AUTO_SERIALIZATION();

// Structure
API_STRUCT() struct TestAttribute : public ISerializable
{
DECLARE_SCRIPTING_TYPE_MINIMAL(TestAttribute);
API_AUTO_SERIALIZATION();

// Enumeration
API_ENUM() enum TestEnum
{
E1, E2,
};

// Enum
API_FIELD() TestEnum Enum = E1;
};

// Attributes
API_FIELD() Array<TestAttribute> Attributes;
// Enum
API_FIELD() TestAttribute::TestEnum Enum = TestAttribute::E1;
};

// Test compilation with nested types.
API_CLASS() class TestNesting2 : public SerializableScriptingObject
{
DECLARE_SCRIPTING_TYPE(TestNesting2);
API_AUTO_SERIALIZATION();

// Structure
API_STRUCT() struct TestAttribute
{
DECLARE_SCRIPTING_TYPE_MINIMAL(TestAttribute);

// Enumeration
API_ENUM() enum TestEnum
{
E1, E2,
};
};

// Attributes
API_FIELD() Array<TestNesting::TestAttribute> Attributes;
// Enum
API_FIELD() TestNesting::TestAttribute::TestEnum Enum = TestNesting::TestAttribute::E1;
};

// Test structure.
API_STRUCT(NoDefault) struct TestStruct : public ISerializable
Expand Down

0 comments on commit 35ddfc2

Please sign in to comment.