https://github.com/ragmaanir/kontrakt
Simple design by contract for crystal
https://github.com/ragmaanir/kontrakt
assertions crystal design-by-contracts
Last synced: about 1 year ago
JSON representation
Simple design by contract for crystal
- Host: GitHub
- URL: https://github.com/ragmaanir/kontrakt
- Owner: Ragmaanir
- License: mit
- Created: 2016-01-22T20:52:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2021-05-05T00:50:51.000Z (almost 5 years ago)
- Last Synced: 2025-01-14T01:12:28.674Z (about 1 year ago)
- Topics: assertions, crystal, design-by-contracts
- Language: Crystal
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kontrakt [](https://travis-ci.org/Ragmaanir/kontrakt)
Kontrakt provides two macros to implement very simple design-by-contract style checks.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
kontrakt:
github: ragmaanir/kontrakt
```
## Usage
```crystal
require "kontrakt"
Kontrakt.precondition(1 == 5) # raises
Kontrakt.postcondition(3 == 3 && true != false) # passes
```
To disable the conditions set DISABLE_CONTRACTS env var:
```crystal
DISABLE_CONTRACTS=1 crystal spec
```
## TODO
- output the values of the variables used
- evaluate partial expressions like power_assert.cr. maybe only show leaf-values, e.g. dont show `x && y`, just show `x` and `y`