Skip to content

Assertion chores, fixes, documentation and new test - #84

Merged
rouson merged 11 commits into
mainfrom
wrap-assert-assert
Aug 7, 2025
Merged

Assertion chores, fixes, documentation and new test#84
rouson merged 11 commits into
mainfrom
wrap-assert-assert

Conversation

@rouson

@rouson rouson commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

This PR
1. Adds a test of the removal of the call_assert_julienne function-like macro when the ASSERTIONS macro is undefined,
2. Fixes a character array constructor to have same-length elements.
3. Improves the documentation of the julienne_assert subroutine in comments.
4. Rewrites some assertions for clarity (e.g., reversing operands to clarify the operand roles as actual versus expected values).

rouson and others added 10 commits August 5, 2025 20:21
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.
Comment thread README.md
Comment thread README.md
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
rouson force-pushed the wrap-assert-assert branch from 3e3599c to 655e848 Compare August 7, 2025 06:39
@rouson
rouson merged commit 8bae5de into main Aug 7, 2025
8 checks passed
@rouson
rouson deleted the wrap-assert-assert branch August 7, 2025 06:48
@rouson rouson mentioned this pull request Aug 7, 2025
@rouson rouson changed the title Add specific procedure for call_julienne_assert_ generic interface Assertion chores, fixes, documentation and new test Aug 7, 2025

@bonachea bonachea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rouson I realize you already merged this PR, but here's an improvement that might be worth adding.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bonachea nice! I'll try this solution.

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.

2 participants