This commit is contained in:
Araq 2014-11-25 23:10:22 +01:00
commit c1930f1b6e

View file

@ -2965,16 +2965,13 @@ when true:
THide(raiseAssert)(msg) THide(raiseAssert)(msg)
template assert*(cond: bool, msg = "") = template assert*(cond: bool, msg = "") =
## Raises ``EAssertionFailure`` with `msg` if `cond` is false. ## Raises ``AssertionError`` with `msg` if `cond` is false. Note
## ## that ``AssertionError`` is hidden from the effect system, so it doesn't
## Provides a means to implement `programming by contracts`:idx: in Nim. ## produce ``{.raises: [AssertionError].}``. This exception is only supposed
## ``assert`` evaluates expression ``cond`` and if ``cond`` is false, it ## to be caught by unit testing frameworks.
## raises an ``EAssertionFailure`` exception. However, the compiler may not ## The compiler may not generate any code at all for ``assert`` if it is
## generate any code at all for ``assert`` if it is advised to do so through ## advised to do so through the ``-d:release`` or ``--assertions:off``
## the ``-d:release`` or ``--assertions:off`` `command line switches ## `command line switches <nimc.html#command-line-switches>`_.
## <nimc.html#command-line-switches>`_.
##
## Use ``assert`` for debugging purposes only.
bind instantiationInfo bind instantiationInfo
mixin failedAssertImpl mixin failedAssertImpl
when compileOption("assertions"): when compileOption("assertions"):