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:
parent
8b7dd19f4b
commit
568e54821d
2 changed files with 67 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue