1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added 'interface' and 'enum' constraints

This commit is contained in:
Brian Fiete 2020-11-10 05:44:23 -08:00
parent f63b9236d0
commit f41365a58e
8 changed files with 110 additions and 27 deletions

View file

@ -132,16 +132,23 @@ namespace Tests
return 1;
}
public static int MethodA<T>(T val) where T : ValueType
public static int MethodA<T>(T val) where T : struct
{
return 2;
}
public static int MethodA<T>(T val) where T : Enum
public static int MethodA<T>(T val) where T : enum
{
int val2 = (int)val;
T val3 = 0;
return 3;
}
public static int MethodA<T>(T val) where T : interface
{
return 4;
}
public struct Entry
{
public static int operator<=>(Entry lhs, Entry rhs)
@ -200,9 +207,12 @@ namespace Tests
LibA.LibA0.Alloc<ClassA>();
LibA.LibA0.Alloc<ClassB>();
IDisposable iDisp = null;
Test.Assert(MethodA("") == 1);
Test.Assert(MethodA(1.2f) == 2);
Test.Assert(MethodA(TypeCode.Boolean) == 3);
Test.Assert(MethodA(iDisp) == 4);
ClassC cc = scope .();
Test.Assert(ClassC.mInstance == cc);