prevent simple Any self-assignment

This commit is contained in:
Michael Davidsaver
2023-02-13 08:28:35 -08:00
parent e0a8572c2d
commit 4029f5ac3c
2 changed files with 24 additions and 2 deletions
+20 -1
View File
@@ -98,6 +98,24 @@ void testAssignUnion()
testTrue(val["->"].valid());
}
void testAssignAny()
{
testDiag("%s", __func__);
auto val = TypeDef(TypeCode::Any).create();
// check the simple self assignment is an error.
testThrows<std::logic_error>([&val](){
val.from(val);
});
val = 42;
testThrows<std::logic_error>([&val](){
val.from(val);
});
}
void testName()
{
testDiag("%s", __func__);
@@ -416,11 +434,12 @@ void testClear()
MAIN(testdata)
{
testPlan(146);
testPlan(148);
testSetup();
testTraverse();
testAssign();
testAssignUnion();
testAssignAny();
testName();
testIterStruct();
testIterUnion();