Assertions: Difference between revisions

Content added Content deleted
(→‎{{header|PARI/GP}}: more traditional PARI)
Line 644: Line 644:
{{trans|C}}
{{trans|C}}
<lang C>#include <assert.h>
<lang C>#include <assert.h>
#include <pari/pari.h>


void
void
test()
test()
{
{
int a;
GEN a;
// ... input or change a here
// ... input or change a here


assert(a == 42); // Aborts program if a is not 42, unless the NDEBUG macro was defined
assert(equalis(a, 42)); /* Aborts program if a is not 42, unless the NDEBUG macro was defined */
}</lang>
}</lang>

More common is the use of <code>pari_err_BUG</code> in such cases:
<lang C>if (!equalis(a, 42)) pari_err_BUG("this_function_name (expected a = 42)");</lang>


=={{header|Pascal}}==
=={{header|Pascal}}==