test explicitly typed ANY assignment

This commit is contained in:
Michael Davidsaver
2026-01-19 19:16:09 -08:00
parent a7d77da776
commit 12eeb42f6b
+14 -2
View File
@@ -124,8 +124,20 @@ void testAssignAny()
val = 42;
// automagic ANY assignment promotes to StoreType
testEq(val["->"].type(), TypeCode::Int64);
testEq(val.as<int64_t>(), 42);
{
auto us = TypeDef(TypeCode::UInt32).create();
us = -1;
val.from(us); // typed ANY assignment
}
testEq(val["->"].type(), TypeCode::UInt32);
testEq(val.as<uint64_t>(), 0xffffffff);
testThrows<std::logic_error>([&val](){
val.from(val);
val.from(val); // self assignment would create infinite recursion
});
}
@@ -550,7 +562,7 @@ void test_cache_sync()
MAIN(testdata)
{
testPlan(189);
testPlan(193);
testSetup();
testTraverse();
testAssign();