2021-01-02 08:11:07 -08:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
{
|
|
|
|
class Cascades
|
|
|
|
{
|
2021-01-02 08:51:04 -08:00
|
|
|
struct StructA
|
2021-01-02 08:11:07 -08:00
|
|
|
{
|
2021-01-02 08:51:04 -08:00
|
|
|
public static int sDiscardCount;
|
|
|
|
public void ReturnValueDiscarded()
|
|
|
|
{
|
|
|
|
sDiscardCount++;
|
|
|
|
}
|
2021-01-02 08:11:07 -08:00
|
|
|
|
2021-01-02 08:51:04 -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
|
|
|
}
|
|
|
|
|
2021-01-02 08:51:04 -08:00
|
|
|
static StructA MethodB(int a, out float b)
|
2021-01-02 08:11:07 -08:00
|
|
|
{
|
|
|
|
b = 100;
|
2021-01-02 08:51:04 -08:00
|
|
|
return .();
|
2021-01-02 08:11:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public static void TestBasics()
|
|
|
|
{
|
2021-01-02 08:51:04 -08:00
|
|
|
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);
|
2021-01-02 08:51:04 -08:00
|
|
|
Test.Assert(StructA.sDiscardCount == 3);
|
2021-01-02 08:11:07 -08:00
|
|
|
Test.Assert(a == 12);
|
2021-01-02 08:51:04 -08:00
|
|
|
|
2021-01-02 08:11:07 -08:00
|
|
|
var (b, c) = MethodA(.. 12, .. 2.3f);
|
2021-01-02 08:51:04 -08:00
|
|
|
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);
|
2021-01-02 08:51:04 -08:00
|
|
|
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);
|
2021-01-02 08:51:04 -08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|