1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 23:56:05 +02:00
Beef/IDEHelper/Tests/src/Properties.bf

92 lines
1.2 KiB
Beef
Raw Normal View History

2020-04-10 07:53:56 -07:00
#pragma warning disable 168
using System;
namespace Tests
{
class Properties
{
struct StructA
{
public int mA = 111;
public this()
{
}
public this(int a)
{
mA = a;
}
}
struct StructB
{
2020-05-08 16:35:05 -07:00
public StructA B { get; set mut; }
2020-04-10 07:53:56 -07:00
int mZ = 9;
public this()
{
B = .();
}
}
struct StructC
{
public StructA B { get; }
int mZ = 9;
public this()
{
B = .();
}
}
class ClassB
{
public StructA B { get; set; }
2020-08-03 06:09:45 -07:00
public int IVal { get => 1; }
public virtual int IVal2 { get => 2; }
2020-04-10 07:53:56 -07:00
int mZ = 9;
public this()
{
}
}
2020-08-03 06:09:45 -07:00
class ClassC : ClassB
{
public new int IVal { get => base.IVal + 100; }
public override int IVal2 { get => base.IVal2 + 100; }
}
2020-04-10 07:53:56 -07:00
[Test]
public static void TestBasics()
{
StructB sb = .();
StructA sa = sb.B;
Test.Assert(sa.mA == 111);
sb.B = .(222);
sa = sb.B;
Test.Assert(sa.mA == 222);
ClassB cb = scope .();
sa = cb.B;
Test.Assert(sa.mA == 0);
cb.B = .(333);
sa = cb.B;
Test.Assert(sa.mA == 333);
2020-08-03 06:09:45 -07:00
ClassC cc = scope .();
Test.Assert(cc.IVal == 101);
Test.Assert(cc.IVal2 == 102);
ClassB cb2 = cc;
Test.Assert(cb2.IVal == 1);
Test.Assert(cb2.IVal2 == 102);
2020-04-10 07:53:56 -07:00
}
}
}