self-explain
v0.11.0
Published
self explained tools - starting with "assert"
Downloads
90
Readme
self-explained
self explained tools - starting with "assert"
Install
$ npm install self-explained
Use
var assert = require('self-exlain').assert;
var alpha = 10;
var betha = 7;
assert(alpha / 2 > betha -1);
It controls the expression like assert
does.
If the expression evaluates to false
it will show the expression and the value.
(also throws the Exception)
ASSERT FAILED
alpha / 2 > betha -1 ==== false
Much more info
var assert = require('self-exlain').assert;
var alpha = 10;
var betha = 7;
eval(assert(alpha / 2 > betha -1));
Adding eval
to the assert It will shows the evaluation of all subexpressions
ASSERT FAILED
alpha / 2 > betha -1 ==== false
alpha / 2 ==== 5
betha -1 ==== 6
alpha ==== 10
betha ==== 7
Exceptions
Function assertCatch
controls that an Error been throwed.
assertCatch(function{
if(error){
throw new Error('an error');
}
}, /an error/);
Tests with real devices
NPM version | Device | OS | nav ------------|------------------------|---------------|--------------- 0.10.0 | HTC Desire | Android 2.2.2 | Android 2.2.2 0.10.0 | Samgsung Galaxy Note 4 | Android 5.1.1 | Samsung Internet 4.0.0 0.10.2 | Samgsung Galaxy Note 4 | Android 6.0.1 | Chrome Mobile 50.0.2661 0.10.0 | Blue Vivo Air LTE | Android 5.0.2 | Chrome Mobile 50.0.2661 0.10.0 | iPad mini Retina | iOS 8.4.0 | Mobile Safari 8.0.0 0.10.0 | VMWare | WinXP | IE 8.0.0