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

Named arguments

This commit is contained in:
Brian Fiete 2022-06-24 18:41:54 -07:00
parent d204922403
commit 79320652e3
15 changed files with 341 additions and 37 deletions

View file

@ -182,6 +182,24 @@ namespace Tests
saPtr.mA += 1000;
}
static int Named(int p1, float p2, int p3)
{
return 10000 + p1*100 + (int)p2*10 + p3;
}
static int Named(int p0, int p1, float p2)
{
return 20000 + p0*100 + p1*10 + (.)p2;
}
static int Named(int p0=1, int p1=2, double p2=3)
{
return 30000 + p0*100 + p1*10 + (.)p2;
}
static int sIdx = 0;
static int GetNext() => ++sIdx;
[Test]
public static void TestBasics()
{
@ -239,6 +257,14 @@ namespace Tests
Test.Assert(sa4.mA == 400);
InStructA(sa4);
Test.Assert(sa4.mA == 1400);
Test.Assert(Named(1, 2, p3:3) == 10123);
Test.Assert(Named(p1: 1, 2, p3: 3) == 10123);
Test.Assert(Named(p0: 1, 2, 3) == 20123);
Test.Assert(Named(1, p1:2, 3) == 20123);
Test.Assert(Named(p3:GetNext(), p2:GetNext(), p1:GetNext()) == 10321);
Test.Assert(Named(p2:GetNext(), p1:GetNext(), p0:GetNext()) == 20654);
Test.Assert(Named(p1:9) == 30193);
}
}
}