assertion

Quick assertions and traces with macros
https://github.com/protocubo/assertion.hx

To install, run:

haxelib install assertion 1.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

Quick assertions and traces with macros

screenshot from 2017-03-17 04-08-57

Usage

import Assertion.*;
[...]
var foo = "a";

// basic `assert`, that throws if the condition fails
assert(foo == "bar");

// trace some context if the assertion fails
// you can add as many expressions to trace as you need
assert(foo == "bar", foo, Sys.systemName());

// trace expressions consisting of string literals are automatically threated as descriptions
assert(foo.length == 3, "correct length at least");

// if you just want a warning, instead of a throw, use `weakAssert`
weakAssert(foo == "bar");

// if you just want to trace like us, use `show`
show(foo, Sys.systemName(), "show everything");

Configuring

Assertion works out of the box without any configuration, but in same cases you might want to change or disable certain default behaviors.

You can configure the library both at compile time and runtime.

Compile time configuration

Use -D ASSERTION_NO_ASSERT to disable the generation of all assertions (both regular and weak).

You can also use -D ASSERTION_NO_WEAK_ASSERT to only disable the generation of weak assertions. Similarly, you can disable the generation of code for show with -D ASSERTION_NO_SHOW.

Runtime configuration

Similarly to the compile time settings, you can use the following variables to alter the behavior of Assertion at runtime:

  • Assertion.enableAssert (defaults to true)
  • Assertion.enableWeakAssert (defaults to true)
  • Assertion.enableShow (defaults to true)
Contributors
jonasmalacofilho
protocubo
Version
1.0.0
Published
1 year ago
License
BSD

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github