chai-increasing
Chai 匹配器,用于递增/递减序列
一个用于在 chai 中对 递增/递减序列 进行断言的插件。
用法
单调递增/递减
expect([1,2,2,3,3,4]).to.be.increasing;
expect([5,4,4,4,4,3]).to.be.decreasing;
expect([1,1,1,1,1,1]).to.be.increasing;
expect([1,1,1,1,1,1]).to.be.decreasing;
严格递增/递减
expect([1,2,3,4,5]).to.be.strictly.increasing;
expect([1,2,3,3,4,5]).not.to.be.strictly.increasing;
expect([10,9,8,7,6]).to.be.strictly.increasing;
expect([10,9,8,7,7]).not.to.be.strictly.decreasing;
空数组 空虚地 递增/递减
expect([]).to.be.increasing;
expect([]).to.be.decreasing;
expect([]).to.be.strictly.increasing;
expect([]).to.be.strictly.decreasing;
额外内容
// supports Strings, Floats and Immutable.js Lists
expect(['Apple','Banana','Coconut']).to.be.strictly.increasing;
expect([1.15, 1.75, 3.28, 4.96]).to.be.strictly.increasing;
expect(Immutable.List.of([1,2,3,4])).to.be.strictly.increasing;
非递减/非递增别名
// "nondecreasing" and "nonincreasing" may be used instead
// of "increasing" and "decreasing" for clarity; the behaviour is the same.
expect([1,1,1]).to.be.increasing;
expect([1,1,1]).to.be.nondecreasing;
安装
npm install chai-increasing --save-dev
var chai = require('chai');
chai.use(require('chai-increasing'));
许可证
MIT 许可证。
版权所有 © 2016 James Lawson