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

Fixes some handling of const payload enums cases

This commit is contained in:
Brian Fiete 2025-02-04 10:23:22 -08:00
parent 8b7dd19f4b
commit 568e54821d
2 changed files with 67 additions and 3 deletions

View file

@ -34,6 +34,13 @@ namespace Tests
}
}
enum ETest
{
case A(int a);
case B(float f);
case C;
}
[Test]
public static void TestBasics()
{
@ -65,6 +72,38 @@ namespace Tests
result = 4;
}
Test.Assert(result == 4);
result = 0;
const int constVal = 123;
switch (constVal)
{
case 10:
result = 1;
case 123:
result = 2;
default:
result = 3;
}
Test.Assert(result == 2);
result = 99;
const Result<int> iResult = .Err;
bool eq = iResult case .Ok(ref result);
Test.Assert(result == 99);
const ETest t = .B(234.5f);
switch (t)
{
case .A(let a):
result = 1;
case .B(let b):
result = (.)b;
case .C:
result = 3;
default:
result = 4;
}
Test.Assert(result == 234);
}
}
}