Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Print correct file/line when a subroutine contains an assert. #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Xeom
Copy link
Contributor

@Xeom Xeom commented Nov 4, 2024

Tests such as asserts were implemented as macros containing two parts:

    snow_fail_update(); // Update the globally stored file and line number
    _asserteq(thing 1, thing 2); // Perform a check

This falls down if "thing 1" or "thing 2" contain assertions themselves, which themselves update the globally stored file and line number. If the outer assertion then fails, it reports the wrong file and line number.

To fix this, add a struct _snow_explanation that is created in assertion macros, and is used to update the global file and line number only once the actual failure is triggered.

Tests such as asserts were implemented as macros containing two parts:

    snow_fail_update(); // Update the globally stored file and line number
    _asserteq(thing 1, thing 2); // Perform a check

This falls down if "thing 1" or "thing 2" contain assertions themselves,
which themselves update the globally stored file and line number. If the
outer assertion then fails, it reports the wrong file and line number.

To fix this, add a struct _snow_explanation that is created in assertion
macros, and is used to update the global file and line number only once
the actual failiure is triggered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant