1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Anonymous subclassing in initializer blocks

This commit is contained in:
Brian Fiete 2025-01-04 10:57:37 -08:00
parent 01c2c35fc3
commit a5e9a33f64
25 changed files with 1111 additions and 608 deletions

View file

@ -30,6 +30,21 @@ class Anonymous
} mCoords;
}
struct StructC
{
public int mA;
public this(int a)
{
mA = a;
}
}
class ClassA
{
public int Val = 123;
}
[Test]
public static void TestBasics()
{
@ -47,5 +62,28 @@ class Anonymous
StructB sb = default;
sb.mX = 345;
Test.Assert(sb.mY == 345);
var sc = StructC(456)
{
public int mB = 567;
{
_.mB += 1000;
},
mB += 10000
};
Test.Assert(sc.mA == 456);
Test.Assert(sc.mB == 11567);
var ca = scope ClassA()
{
public override void ToString(String strBuffer)
{
strBuffer.Append("ClassA override");
}
};
var str = ca.ToString(.. scope .());
Test.Assert(str == "ClassA override");
}
}