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

Improved const handling of char8*

This commit is contained in:
Brian Fiete 2025-02-23 14:09:33 -08:00
parent b075f8dbf3
commit 7f3b3f2e09
4 changed files with 98 additions and 4 deletions

View file

@ -85,6 +85,20 @@ namespace Tests
}
}
struct SpecialId : int
{
public const Self CONST = (.)(int)(void*)(char8*)"ABC";
public static Self operator implicit(String str) => (.)(int)(void*)(char8*)str;
}
public static void TestStr(SpecialId specialId)
{
char8* ptr = (.)(void*)(int)specialId;
StringView sv = .(ptr);
Test.Assert(sv == "ABC");
}
[Test]
public static void TestBasics()
{
@ -101,6 +115,9 @@ namespace Tests
Test.Assert(TestRangedArray<int32, -3...3>.cRangeEnd - TestRangedArray<int32, -3...3>.cRangeStart == 7);
Test.Assert(TestRangedArray<int32, -3...>.cError == "Invalid type: -3...^1");
TestStr(.CONST);
TestStr("ABC");
}
}
}