1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-30 13:26:00 +02:00
Beef/IDEHelper/Tests/src/Cascades.bf

66 lines
1.1 KiB
Beef
Raw Normal View History

2021-01-02 08:11:07 -08:00
using System;
namespace Tests
{
class Cascades
{
struct StructA
2021-01-02 08:11:07 -08:00
{
public static int sDiscardCount;
public void ReturnValueDiscarded()
{
sDiscardCount++;
}
2021-01-02 08:11:07 -08:00
public void HandleResult()
{
}
public StructA Method0(int a)
{
return .();
}
}
static StructA MethodA(int a, float b)
{
return .();
2021-01-02 08:11:07 -08:00
}
static StructA MethodB(int a, out float b)
2021-01-02 08:11:07 -08:00
{
b = 100;
return .();
2021-01-02 08:11:07 -08:00
}
[Test]
public static void TestBasics()
{
MethodA(1, 1.2f);
Test.Assert(StructA.sDiscardCount == 1);
StructA sa = .();
sa.Method0(1)..Method0(2).HandleResult();
Test.Assert(StructA.sDiscardCount == 2);
2021-01-02 08:11:07 -08:00
int a = MethodA(.. 12, 2.3f);
Test.Assert(StructA.sDiscardCount == 3);
2021-01-02 08:11:07 -08:00
Test.Assert(a == 12);
2021-01-02 08:11:07 -08:00
var (b, c) = MethodA(.. 12, .. 2.3f);
Test.Assert(StructA.sDiscardCount == 4);
2021-01-02 08:11:07 -08:00
Test.Assert(b == 12);
Test.Assert(c == 2.3f);
var d = MethodA(.. 12, .. 2.3f);
Test.Assert(StructA.sDiscardCount == 5);
2021-01-02 08:11:07 -08:00
Test.Assert(d == (12, 2.3f));
var f = ref MethodB(12, .. var e);
Test.Assert(StructA.sDiscardCount == 6);
2021-01-02 08:11:07 -08:00
e += 23;
Test.Assert(e == (int)123);
Test.Assert(f == (int)123);
}
}
}