1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 07:14:09 +02:00

Updated tests to fix some Win32 issues

This commit is contained in:
Brian Fiete 2019-12-21 05:30:22 -08:00
parent 79149d6a7c
commit fbb06862b3
3 changed files with 58 additions and 0 deletions

View file

@ -32,6 +32,25 @@ namespace Tests
{
return mA + mB + a;
}
public void TestLambda() mut
{
delegate int(ref int a, ref int b) dlg = scope [&] (a, b) =>
{
a += 20;
b += 30;
mA++;
return mA + a + b;
};
mA = 100;
int testA = 8;
int testB = 9;
Test.Assert(dlg(ref testA, ref testB) == 100+1 + 20+8 + 30+9);
Test.Assert(testA == 28);
Test.Assert(testB == 39);
Test.Assert(mA == 101);
}
}
struct NonSplattable
@ -53,6 +72,30 @@ namespace Tests
}
}
class ClassA
{
public int mA;
public void TestLambda()
{
delegate int(ref int a, ref int b) dlg = scope (a, b) =>
{
a += 20;
b += 30;
mA++;
return mA + a + b;
};
mA = 100;
int testA = 8;
int testB = 9;
Test.Assert(dlg(ref testA, ref testB) == 100+1 + 20+8 + 30+9);
Test.Assert(testA == 28);
Test.Assert(testB == 39);
Test.Assert(mA == 101);
}
}
[Test]
public static void TestBasics()
{
@ -89,6 +132,10 @@ namespace Tests
dlg = scope => (ref val2).NonMutMethod;
Test.Assert(dlg(9) == 319);
Test.Assert(val2.mB == 300);
val1.TestLambda();
ClassA ca = scope .();
ca.TestLambda();
}
}
}