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

Make it explicit that tools can show the value of variables for asserts #3641

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

HansOlsson
Copy link
Collaborator

See:
modelica/ModelicaStandardLibrary#4519 and modelica/ModelicaStandardLibrary#4399 for background.

The reason for "may" is:

I thought it was sufficiently important to make it normative.

See: modelica/ModelicaStandardLibrary#4519 and modelica/ModelicaStandardLibrary#4399

The reason for "may" is:
- To not require the value to be duplicated, for cases such as: modelica/ModelicaStandardLibrary#4399
- Support even smarter debugging.

I thought it was sufficiently important to make it normative.
@HansOlsson HansOlsson added this to the 2025-February milestone Feb 5, 2025
@@ -518,6 +519,11 @@ \subsection{assert}\label{assert}
AssertionLevel.warning);
assert(T > 200 and T < 500, "Medium model outside feasible region");
\end{lstlisting}

It is recommended that asserts have a simple message as above, formulated with the recommended tool behavior in mind.
Tools are recommended to include the failed condition in the message.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was already stated above.

Suggested change
Tools are recommended to include the failed condition in the message.


It is recommended that asserts have a simple message as above, formulated with the recommended tool behavior in mind.
Tools are recommended to include the failed condition in the message.
Tools are also (especially for literal strings) recommended to automatically include the values of relevant variables, as part of the log or interactively accessible.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Essentially already stated above.

Suggested change
Tools are also (especially for literal strings) recommended to automatically include the values of relevant variables, as part of the log or interactively accessible.

It is recommended that asserts have a simple message as above, formulated with the recommended tool behavior in mind.
Tools are recommended to include the failed condition in the message.
Tools are also (especially for literal strings) recommended to automatically include the values of relevant variables, as part of the log or interactively accessible.
Writing \lstinline!assert(T<500, "Temperature = "+String(T)+" was above 500");! is thus not recommended, and is likely to lead to duplicated information -- although tools may have specific compatibility handling of such cases.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be sufficient to say likely; just let tools to their "clever" thing without mentioning it in the specification. Also remove punctuation at end of inline code:

Suggested change
Writing \lstinline!assert(T<500, "Temperature = "+String(T)+" was above 500");! is thus not recommended, and is likely to lead to duplicated information -- although tools may have specific compatibility handling of such cases.
Writing \lstinline!assert(T<500, "Temperature = "+String(T)+" was above 500")! is thus not recommended, and is likely to lead to duplicated information.

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