Closed elect86 closed 1 year ago
Thank you!
Corrected e058397. Amusingly due to printf handling, it had no side-effect.
Also, is it on purpouse to have macro such as IM_CHECK
executing _EXPR
twice in a row?
Normally, with plain property comparisons I wouldn't mind at all, but there are some times when more complicate expressions provoke the consumption of a frame, such as here
Also, is it on purpouse to have macro such as IM_CHECK executing _EXPR twice in a row?
They don't, this is not what I see in the code.
#EXPR
is compile-time stringification of the expression so it can be reported in the assert.
I am actually now adding a test to ensure this property doesn't break:
This passes:
// ## Test that our IM_CHECK_xxx macros don't expand parameters more than once.
t = IM_REGISTER_TEST(e, "testengine", "testengine_checks");
t->TestFunc = [](ImGuiTestContext* ctx)
{
int n = 0;
IM_CHECK(n++ == 0);
IM_CHECK(n == 1);
IM_CHECK_EQ(n, 1);
IM_CHECK_EQ(n++, 1);
IM_CHECK_EQ(n, 2);
};
Set one breakpoint before, one after and one in the function ::ItemInfo
itself (you can differentiate the two sequential calls from their arguments)
You will see you will hit the function twice
ItemInfo() may call itself recursively when using **/ If you look at IM_CHECK() at no point the expression is expanded twice.
I just double checked, it looks as I say
I hit the breakpoint in the ::ItemInfo
right at the begin at if (IsError())
once, then I go step by step (F10) through all the function till the end, then continue, then I hit the breakpoint again with the very same argument "**/TestMenu/"
Try yourself
It should be executed twice also by looking at the code, once in the assert and a second time in the if
:
{ IM_ASSERT(_EXPR); } if (!(bool)(_EXPR)) return; }
This code doesn't exist any more, you are referring to an old version of the code.
uh, I'm still at 1.89.4
sorry for the noise, I'll update
https://github.com/ocornut/imgui_test_engine/blob/main/imgui_test_suite/imgui_tests_tables.cpp#L359