extends assert of node 扩展node原生的Assert功能
Usage for English is Coming soon...
使用nodejs
$ npm install --save assertrue
const assert = require('assertrue');
- 说明:assertrue中已经包含原生assert的全部功能,不需要再额外引入assert
assert.isTrue(true); //ok
assert.isTrue(1); //ok
assert.isTrue('a'); //ok
assert.isTrue(false); //AssertionError
assert.isTrue(0); //AssertionError
assert.isTrue(''); //AssertionError
assert.isStrictTrue(true); //ok
assert.isStrictTrue(1); //AssertionError
assert.isStrictTrue('a'); //AssertionError
assert.isStrictTrue(false); //AssertionError
assert.isStrictTrue(0); //AssertionError
assert.isStrictTrue(''); //AssertionError
assert.isNaN(NaN); //ok
assert.isNaN('a'); //ok
assert.isNaN({}); //ok
assert.isNaN(1); //AssertionError
assert.isNaN('1'); //AssertionError
assert.isNaN(true); //AssertionError
assert.isStrictNaN(NaN); //ok
assert.isStrictNaN('a'); //AssertionError
assert.isStrictNaN({}); //AssertionError
assert.isStrictNaN(1); //AssertionError
assert.isStrictNaN('1'); //AssertionError
assert.isStrictNaN(true); //AssertionError
assert.isStrictString('a'); //ok
assert.isStrictString(['a']); //ok
assert.isStrictFunction(()=>{}); //ok
assert.isStrictRegExp(/\w+/ig); //ok
assert.isStrictBoolean(true); //ok
assert.isStrictNumber(1); //ok
assert.is(1, Number); //ok
assert.is(1, 'Number'); //ok
class Super {}
class Sub extends Super {}
assert.is(new Sub(), Sub); //ok
assert.is(new Sub(), Super); //ok
assert.is(new Super(), Super); //ok
assert.is(new Super(), Sub); //AssertionError
assert.is(new Sub(), 'Super'); //AssertionError
class Super {}
class Sub extends Super {}
assert.isAssignableFrom(Super, Sub); //ok
assert.isAssignableFrom(Super, Super); //ok
assert.isAssignableFrom(Sub, Sub); //ok
assert.isAssignableFrom(Sub, Super); //AssertionError
class Super {}
class Sub extends Super {}
assert.isAssignableFrom(Sub, Super); //ok
assert.isAssignableFrom(Super, Super); //ok
assert.isAssignableFrom(Sub, Sub); //ok
assert.isAssignableFrom(Super, Sub); //AssertionError
增加对class继承关系的断言
重命名为assertrue
增加 Travis CI 支持
新增对各种类型的断言
正式启动项目
More docs and examples, to be continue... 更多接口文档的案例,未完待补充...