assert
DbC library for Nim providing precondition and postcondition assertions
Summary
| Latest Version | 0.1.2 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:26 |
Tags
Authors
- alexekdahl
Installation
nimble install assert
choosenim install assert
git clone https://github.com/alexekdahl/assert
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| assert | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Dependencies
| Package | Version | Optional |
|---|---|---|
| nim >= | 2.2.2 | No |
Source
| Repository | https://github.com/alexekdahl/assert |
|---|---|
| Homepage | https://github.com/alexekdahl/assert |
| Registry Source | nimble_official |
README
Design by Contract for Nim
A lightweight Design by Contract implementation for Nim allowing you to enforce preconditions and postconditions
Installation
nimble install assert
Usage
import assert
import math
proc divide(a, b: int): int {.contract.} =
## Integer division of a by b.
## Requires:
## b != 0
## Ensures:
## result * b == a
result = a div b
Compile Options
-
Regular Build: Contracts fully enabled
nim c program.nim -
Production Build: No contract checks (zero overhead)
nim c -d:noContracts program.nim
Note
When a contract is violated, the program terminates with an error message