1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Fixes for type initializer blocks

This commit is contained in:
Brian Fiete 2020-12-07 10:58:02 -08:00
parent 9cd47a784b
commit 34dcd47dd5
6 changed files with 98 additions and 11 deletions

View file

@ -87,6 +87,22 @@ namespace LibA
return lhs == rhs;
}
}
class LibA3
{
public int mA = 3;
public static LibA3 sLibA3 = new LibA3() ~ delete _;
public this()
{
mA++;
}
}
class LibA4
{
public int mA;
}
}
class LibClassA

View file

@ -49,6 +49,27 @@ extension LibClassA
}
}
namespace LibA
{
extension LibA3
{
public int mB = 7;
this
{
mA += 10;
}
}
extension LibA4
{
this
{
mA += 10;
}
}
}
static
{
public static int Overload0(int16 a)

View file

@ -55,6 +55,17 @@ extension LibClassA
}
}
namespace LibA
{
extension LibA3
{
this
{
mA += 100;
}
}
}
namespace Tests
{
class Extensions
@ -267,6 +278,12 @@ namespace Tests
Test.Assert(ca.mA == 107);
delete ca;
Test.Assert(LibClassA.sMagic == 7771);
LibA.LibA3 la3 = scope .();
Test.Assert(la3.mA == 114);
Test.Assert(la3.mB == 7);
LibA.LibA4 la4 = scope .();
Test.Assert(la4.mA == 10);
}
[Test]

View file

@ -1,9 +1,23 @@
using System;
namespace Tests
{
class Objects
{
class ClassA
{
public int mA = 1;
this
{
mA *= 11;
}
public this()
{
mA += 100;
}
public virtual void MethodA()
{
@ -17,5 +31,12 @@ namespace Tests
base.MethodA();
}
}
[Test]
public static void TestBasics()
{
ClassA ca = scope .();
Test.Assert(ca.mA == 111);
}
}
}