mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-28 04:28:01 +02:00
Initializer expressions
This commit is contained in:
parent
f6e31e4976
commit
229a5aa5c5
17 changed files with 305 additions and 18 deletions
44
IDEHelper/Tests/src/Initializers.bf
Normal file
44
IDEHelper/Tests/src/Initializers.bf
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
|
||||
namespace Tests
|
||||
{
|
||||
class Initializers
|
||||
{
|
||||
struct StructA
|
||||
{
|
||||
public int mA = 123;
|
||||
public int mB;
|
||||
public int mC;
|
||||
public int mD;
|
||||
|
||||
public int ValC
|
||||
{
|
||||
set mut
|
||||
{
|
||||
mC = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(float val, float? val2 = 234) mut
|
||||
{
|
||||
mD += (int)val;
|
||||
mD += (int)val2 * 10;
|
||||
}
|
||||
|
||||
public void Add(int val)
|
||||
{
|
||||
Test.FatalError("Shouldn't be called");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
StructA sa = .() { mB = 345, ValC = 456, 567.8f, 789};
|
||||
Test.Assert(sa.mA == 123);
|
||||
Test.Assert(sa.mB == 345);
|
||||
Test.Assert(sa.mC == 456);
|
||||
Test.Assert(sa.mD == 6036);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue