Questions tagged [assertion]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
25 views

How to print local variable when assertion failed

Given the following code: func[i_] := Module[{k}, k = i; Assert[k > 0, k]]; func[-1] The output is: ...
18
votes
1answer
210 views

Confirm vs Throw

Version 12.2 brought us Confirm and Enclose. What's the point? Is it just that it's a slightly more convenient syntax than ...
2
votes
2answers
161 views

Assert that prints message and aborts computation?

I'd like to add asserts which check for condition, print useful message and abort computation on failure. IE, ...
3
votes
1answer
71 views

Improving `$AssertFunction` to always tell what the assertion test resulted in

I really like this form of assertion failure: On[Assert]; Assert[1 + 1 == True]; Assert::asrttf: Assertion test 1+1==True evaluated to 2==True that is neither ...
17
votes
4answers
963 views

stop notebook evaluation when Assert fails

I would like a notebook evaluation to entirely stop when an Assert fails, without quitting the kernel. Is this possible (e.g., by setting ...
3
votes
1answer
352 views

How to get Mathematica to abort the current evaluation if an assertion fails?

I can turn on assertions, but they don't terminate the current evaluation. For example: ...
34
votes
1answer
1k views

which is better, using Assert[] or manual checks on arguments and other computations?

I never used Asserts in Mathematica, but trying to see what advantage they have over just argument check and additional definitions of the function to capture unwanted input. For example, which one ...