test.js 507 B

123456789101112131415161718192021
  1. var assert = console.assert
  2. var unique = require('array-unique')
  3. var random = require('./')
  4. var iterations = 10000
  5. var number, cache = []
  6. for (var i = 0; i < iterations; i++) {
  7. number = random()
  8. if (number < 0) {
  9. assert(false, 'Random numbers should be greater than or equal to zero')
  10. break
  11. }
  12. if (number >= 1) {
  13. assert(false, 'Random numbers should be less than one')
  14. break
  15. }
  16. cache.push(number)
  17. }
  18. assert(unique(cache).length === iterations, 'Random numbers should be unique')