UI for Zipcoin Blue

test.js 707B

123456789101112131415161718192021222324252627
  1. var test = require('tape')
  2. var unique = require('array-unique')
  3. var random = require('./')
  4. test('it works', function (assert) {
  5. var number, l = 1000, cache = []
  6. for (var i = 0; i < l; i++) {
  7. number = random()
  8. if (number <= 0) {
  9. assert.fail('a random number was less than or equal to zero')
  10. assert.end()
  11. return
  12. }
  13. if (number >= 1) {
  14. assert.fail('a random number was greater than or equal to one')
  15. assert.end()
  16. return
  17. }
  18. cache.push(number)
  19. }
  20. assert.pass('all ' + l + ' random numbers were greater than zero and less than one')
  21. assert.equal(cache.length, unique(cache).length, 'all ' + l + ' random numbers were unique')
  22. assert.end()
  23. })