Assertion (software development): Difference between revisions

Content deleted Content added
Internal link
Tags: Visual edit Mobile edit Mobile web edit
Internal link
Tags: Visual edit Mobile edit Mobile web edit
Line 124:
Some languages, including [[C (programming language)|C]] and [[C++]], can completely remove assertions at compile time using the [[preprocessor]].
 
Similarly, launching the [[Python (programming language)|Python]] interpreter with "-O" (for "optimize") as an argument will cause the Python code generator to not emit any bytecode for asserts.<ref>[https://docs.python.org/3/reference/simple_stmts.html#grammar-token-assert-stmt Official Python Docs, ''assert statement'']</ref>
 
Java requires an option to be passed to the run-time engine in order to ''enable'' assertions. Absent the option, assertions are bypassed, but they always remain in the code unless optimised away by a JIT compiler at run-time or [[dead_code_elimination|excluded at compile time]] via the programmer manually placing each assertion behind an <code>if (false)</code> clause.