mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 23:04:09 +02:00
Made method mutability part of signature and method selection
This commit is contained in:
parent
f795215b44
commit
c49d92b779
7 changed files with 129 additions and 14 deletions
|
@ -31,6 +31,24 @@ namespace Tests
|
|||
|
||||
}
|
||||
|
||||
struct StructA
|
||||
{
|
||||
int mA;
|
||||
|
||||
public int this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
get mut
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void Hey()
|
||||
{
|
||||
|
@ -43,6 +61,11 @@ namespace Tests
|
|||
Test.Assert(value == 234);
|
||||
value = ca[0];
|
||||
Test.Assert(value == 234);
|
||||
|
||||
StructA sa = default;
|
||||
let sa2 = sa;
|
||||
Test.Assert(sa[0] == 2);
|
||||
Test.Assert(sa2[0] == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,35 @@ namespace Tests
|
|||
{
|
||||
public StructA B { get; }
|
||||
|
||||
public int C => 123;
|
||||
[SkipCall]
|
||||
public int D => 123;
|
||||
|
||||
public int E
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
get mut
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
int mZ = 9;
|
||||
|
||||
public int GetVal()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int GetVal() mut
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public this()
|
||||
{
|
||||
B = .();
|
||||
|
@ -73,6 +100,15 @@ namespace Tests
|
|||
sa = sb.B;
|
||||
Test.Assert(sa.mA == 222);
|
||||
|
||||
StructC sc = default;
|
||||
Test.Assert(sc.C == 123);
|
||||
Test.Assert(sc.D == 0);
|
||||
let sc2 = sc;
|
||||
Test.Assert(sc.E == 2);
|
||||
Test.Assert(sc.GetVal() == 4);
|
||||
Test.Assert(sc2.E == 1);
|
||||
Test.Assert(sc2.GetVal() == 3);
|
||||
|
||||
ClassB cb = scope .();
|
||||
sa = cb.B;
|
||||
Test.Assert(sa.mA == 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue