UNPKG

shamjs

Version:
35 lines (34 loc) 985 B
var expect = require('expect.js') var sham = require('../../lib/index') var util = require('../../lib/util/test') var gabble = util.gabble var map = require('../../lib/random/map') describe('random/boolean.js', function () { it('boolean()', function () { gabble(function () { expect( sham.r.boolean() ).to.a('boolean') expect( sham.r.bool() ).to.a('boolean') }) }) it('boolean(1)', function () { var stats = { 'true':[], 'false': [] } gabble(function () { if (sham.r.bool(1)) { stats.true.push(true) } else { stats.false.push(false) } }, 100) stats.true // 预计 循环100次 sham.r.bool(1) 的情况 true 不会超过50,如果超过真的是千年等一回 expect(stats['true'].length).to.within(0, 10) }) })