UNPKG

reign

Version:

A persistent, typed-objects implementation.

36 lines (31 loc) 1.07 kB
'use strict'; var _2 = require('./'); var _3 = _interopRequireDefault(_2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } describe('Float64 Hashes', function () { it('should hash integer values', function () { Array.from({ length: 4096 }, function (_, index) { return index; }).forEach(function (value) { var result = (0, _3.default)(value); result.should.equal(Math.floor(result)); result.should.be.above(-1); result.should.be.below(Math.pow(2, 32) - 1); }); }); it('should hash float values', function () { Array.from({ length: 4096 }, function (_, index) { return index; }).forEach(function (value) { var result = (0, _3.default)(value * Math.random()); result.should.equal(Math.floor(result)); result.should.be.above(-1); result.should.be.below(Math.pow(2, 32) - 1); }); }); benchmark("Default", 1000000, { float64: function float64() { return (0, _3.default)(Math.random() * Math.pow(2, 32)); } }); });