-
Notifications
You must be signed in to change notification settings - Fork 184
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
121 replace assert with check #163
121 replace assert with check #163
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left only two minor comments.
src/stdlib_experimental_error.f90
Outdated
character(*), intent(in), optional :: msg | ||
integer, intent(in), optional :: code | ||
logical, intent(in), optional :: warn | ||
character(*), parameter :: msg_default = 'Test failed.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense if the default message is `'Check failed.' just to be consistent with the subroutine name?
src/stdlib_experimental_error.f90
Outdated
! ! Stops the program with exit code 1 and prints 'Test failed.' | ||
! call check(a == 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an implicit assumption in the examples that a
is not five. It remains to be discussed whether such examples in the docstrings should be self-contained.
@ivan-pi You're right. The latest commit fixes that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with it. I think we should still come up with another function that behaves like I suggested. Obviously we'll have to come up with a new name though.
Thanks, all. @everythingfunctional, let's do a separate issue and PR for your proposal when you're ready. Merging. |
@milancurcic Do we want that users use both |
@jvdp1 I think so. Sorry, I totally forgot about the spec. That should've been part of the original PR. Please go ahead with a draft spec if you don't mind. Thank you! |
This PR implements the
check
subroutine, proposed to replaceassert
for internal testing. Specifically:check
as proposed hereassert
with calls tocheck
assert
fromstdlib_experimental_error
This PR doesn't cover making all
check
calls to print meaningful messages on failure, and to execute them withwarn=.true.
, to allow multiple test failures in a single run. These will be covered in a future PR.This internal testing is meant as temporary until we can do it with
fpm test
as proposed in #162. For now, we consider this as a "good enough" solution that will help us move forward with development while fpm is in the works.Finally, there is also Brad's proposed implementation here which we shouldn't ignore. If there is some support from the community for it, let's discuss and consider it.