mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-23 18:18:00 +02:00
Fix DoPopulateType_CeCheckEnum
This commit is contained in:
parent
8225643598
commit
aa4f9f7dfa
3 changed files with 41 additions and 7 deletions
|
@ -251,15 +251,23 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
[CheckEnum]
|
||||
[CheckPayloadEnum]
|
||||
enum EnumA
|
||||
{
|
||||
case A(int64 aa);
|
||||
case B(float bb);
|
||||
}
|
||||
|
||||
[CheckEnum]
|
||||
enum EnumB
|
||||
{
|
||||
case A = 123;
|
||||
case B = 1000;
|
||||
case C = 1200;
|
||||
}
|
||||
|
||||
[AttributeUsage(.All)]
|
||||
public struct CheckEnumAttribute : Attribute, IComptimeTypeApply
|
||||
public struct CheckPayloadEnumAttribute : Attribute, IComptimeTypeApply
|
||||
{
|
||||
public void ApplyToType(Type type)
|
||||
{
|
||||
|
@ -283,6 +291,26 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(.All)]
|
||||
public struct CheckEnumAttribute : Attribute, IComptimeTypeApply
|
||||
{
|
||||
public void ApplyToType(Type type)
|
||||
{
|
||||
int fieldIdx = 0;
|
||||
for (var field in type.GetFields())
|
||||
{
|
||||
switch (fieldIdx)
|
||||
{
|
||||
case 0:
|
||||
Test.Assert(field.Name == "A");
|
||||
Test.Assert(field.FieldType.UnderlyingType == typeof(int64));
|
||||
}
|
||||
fieldIdx++;
|
||||
}
|
||||
Test.Assert(fieldIdx == 3);
|
||||
}
|
||||
}
|
||||
|
||||
const String cTest0 = Compiler.ReadText("Test0.txt");
|
||||
const String cTest1 = new String('A', 12);
|
||||
const uint8[?] cTest0Binary = Compiler.ReadBinary("Test0.txt");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue