1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 16:40:26 +02:00
Beef/IDEHelper/Tests/src/Anonymous.bf

51 lines
858 B
Beef
Raw Normal View History

2025-01-02 11:42:33 -08:00
using System;
namespace Tests;
class Anonymous
{
struct StructA
{
public [Union] struct { public int mX, mY; } mVals;
[CRepr, SkipCall] struct { public int mA, mB; } GetVals()
{
decltype(GetVals()) retVals;
retVals.mA = 1;
retVals.mB = 2;
return retVals;
}
2025-01-02 16:19:26 -08:00
public enum { Left, Right } GetDirection() => .Right;
public enum : int { A, B, C } Val => .C;
2025-01-02 11:42:33 -08:00
}
struct StructB
{
[Union]
public using struct
{
public int mX;
public int mY;
} mCoords;
}
[Test]
public static void TestBasics()
{
StructA sa = default;
sa.mVals.mX = 123;
Test.Assert(sa.mVals.mY == 123);
var val = sa.[Friend]GetVals();
Test.Assert(val.mA == 0);
Test.Assert(val.mB == 0);
2025-01-02 16:19:26 -08:00
Test.Assert(sa.GetDirection() == .Right);
Test.Assert(sa.Val == .C);
2025-01-02 11:42:33 -08:00
StructB sb = default;
sb.mX = 345;
Test.Assert(sb.mY == 345);
}
}