mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-27 12:08:00 +02:00
Improving auto-implemented properties
This commit is contained in:
parent
66aeb0a302
commit
664078557f
7 changed files with 212 additions and 24 deletions
76
IDEHelper/Tests/src/Properties.bf
Normal file
76
IDEHelper/Tests/src/Properties.bf
Normal file
|
@ -0,0 +1,76 @@
|
|||
#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
|
||||
{
|
||||
public StructA B { get; set; }
|
||||
|
||||
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; }
|
||||
|
||||
int mZ = 9;
|
||||
|
||||
public this()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue