|
|
|
|
|
by samiv
570 days ago
|
|
Your example is an incorrect use of an assert. You never use assert for conditions that are logical (error) conditions that the program is expected to handle. For example your browser handling 404 HTML error is only an error from the user perspective. From the software correctness perspective there's no error, there's just a logical condition that needs to be reasoned about. Compare this to a BUG which is a mistake (an error made by the programmer), for example violating some invariant, going out of bounds on an array etc. This is a scenario where the program is violating its own logic and constraints and as a result is no longer in a valid state. Assert is a tool to catch BUGS made by the programmer and nothing else. |
|
Perhaps I should have been clearer that it was a programming error that allowed the cursor to get to a state where it wasn’t visible.