ocornut / imgui_test_engine

Dear ImGui Automation Engine & Test Suite
386 stars 40 forks source link

Branch never executed #25

Closed elect86 closed 1 year ago

elect86 commented 1 year ago

https://github.com/ocornut/imgui_test_engine/blob/main/imgui_test_suite/imgui_tests_tables.cpp#L359

ocornut commented 1 year ago

Thank you!

elect86 commented 1 year ago

Same goes for https://github.com/ocornut/imgui_test_engine/blob/main/imgui_test_suite/imgui_tests_tables.cpp#L1036-L1047

elect86 commented 1 year ago

Let me exploit this issue

Did you mean %.0f here?

ocornut commented 1 year ago

Corrected e058397. Amusingly due to printf handling, it had no side-effect.

elect86 commented 1 year ago

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

ocornut commented 1 year ago

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);
    };
elect86 commented 1 year ago

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

ocornut commented 1 year ago

ItemInfo() may call itself recursively when using **/ If you look at IM_CHECK() at no point the expression is expanded twice.

elect86 commented 1 year ago

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; }

ocornut commented 1 year ago

This code doesn't exist any more, you are referring to an old version of the code.

elect86 commented 1 year ago

uh, I'm still at 1.89.4

sorry for the noise, I'll update

elect86 commented 1 year ago

This should be renamed to IncludeRangeByIndices (or a new #if shall be added`)