kontrakt

Simple design by contract for crystal

kontrakt Build Status

Kontrakt provides two macros to implement very simple design-by-contract style checks.

Installation

Add this to your application's shard.yml:

dependencies:
  kontrakt:
    github: ragmaanir/kontrakt

Usage

require "kontrakt"

Kontrakt.precondition(1 == 5) # raises
Kontrakt.postcondition(3 == 3 && true != false) # passes

To disable the conditions set DISABLE_CONTRACTS env var:

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
Repository

kontrakt

Owner
Statistic
  • 1
  • 0
  • 0
  • 5
  • 1
  • over 3 years ago
  • January 22, 2016
License

MIT License

Links
Synced at

Thu, 21 Nov 2024 10:02:10 GMT

Languages