mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 23:34:10 +02:00
Improvements to const string generic arg, literal generic args
This commit is contained in:
parent
cd1e65231e
commit
cf5c969d1f
15 changed files with 243 additions and 99 deletions
|
@ -451,6 +451,15 @@ namespace Tests
|
|||
Compiler.Mixin(GetMathString<T, T2>(expr));
|
||||
}
|
||||
|
||||
class GenClass<TDesc> where TDesc : const String
|
||||
{
|
||||
[OnCompile(.TypeInit), Comptime]
|
||||
static void Init()
|
||||
{
|
||||
Compiler.EmitTypeBody(typeof(Self), TDesc);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
@ -527,8 +536,14 @@ namespace Tests
|
|||
|
||||
float math = ComputeMath(2.3f, 2, "*");
|
||||
Test.Assert(math == 4.6f);
|
||||
float math2 = ComputeMath<float, int, const "+">(2.3f, 1, "+");
|
||||
float math2 = ComputeMath<float, int, "+">(2.3f, 1, "+");
|
||||
Test.Assert(math2 == 3.3f);
|
||||
|
||||
GenClass<
|
||||
"""
|
||||
public int mA = 123;
|
||||
"""> genClass = scope .();
|
||||
Test.Assert(genClass.mA == 123);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,6 +409,12 @@ namespace Tests
|
|||
return total;
|
||||
}
|
||||
|
||||
static int CheckString<T>(T str) where T : const String
|
||||
{
|
||||
const bool eq = str == "Abc";
|
||||
return T.Length;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
@ -441,6 +447,11 @@ namespace Tests
|
|||
|
||||
Test.Assert(l2.Front[0] == "2");
|
||||
Test.Assert(l2.Front[1] == "4");
|
||||
|
||||
int len = CheckString("Abc");
|
||||
Test.Assert(len == 3);
|
||||
len = CheckString<"Abcd">("Abcd");
|
||||
Test.Assert(len == 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue