Assertion chores, fixes, documentation and new test - #84
Merged
Conversation
This commit adds a new specific procedure for the call_julienne_assert generic interface. The new procedure, subroutine assert_assert, has one required logical argument in addition to character 'file' and integer 'line' arguments analogous to those in the julienne_assert subroutine. Like julienne_assert, the new subroutine calls the 'assert' in the Assert library (https://go.lbl.gov/assert).
This commit default-initializes the test_diagnosis_t test_passed_ component to .false.
rouson
commented
Aug 6, 2025
rouson
commented
Aug 6, 2025
This commit 1. Adds a test of the removal of the call_assert_julienne function-like macro when the ASSERTIONS macro is undefined and 2. Fixes a character array constructor to have same-length elements. 3. Improves the documenation of the julienne_assert subroutine. 4. Rewrites some assertions for clarity (reversing operands). 5. Removes assert_assert and directs users to the Assert library for similar functionality.
rouson
force-pushed
the
wrap-assert-assert
branch
from
August 7, 2025 06:39
3e3599c to
655e848
Compare
Closed
bonachea
reviewed
Aug 7, 2025
Comment on lines
+11
to
+17
| module procedure julienne_assert | ||
| character(len=:), allocatable :: diagnostics_string | ||
| diagnostics_string = test_diagnosis%diagnostics_string() | ||
| if (present(file)) diagnostics_string = diagnostics_string // " in file " // file | ||
| if (present(line)) diagnostics_string = diagnostics_string // " at line " // string_t(line) | ||
| call assert_always(test_diagnosis%test_passed(), diagnostics_string) | ||
| end procedure |
Member
There was a problem hiding this comment.
Because you are using Assert 3+, this procedure could more simply and efficiently be written as:
module procedure julienne_assert
call assert_always(test_diagnosis%test_passed(), test_diagnosis%diagnostics_string(), file, line)
end procedure
In addition to simplicity, this also has the significant advantage to skipping most of the string-handling overhead for the common case when the assertion is .true. (and the description string is therefore "dead").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR
1. Adds a test of the removal of the
call_assert_juliennefunction-like macro when theASSERTIONSmacro is undefined,2. Fixes a
characterarray constructor to have same-length elements.3. Improves the documentation of the
julienne_assertsubroutine in comments.4. Rewrites some assertions for clarity (e.g., reversing operands to clarify the operand roles as actual versus expected values).