rng class..
This commit is contained in:
parent
3ff375dbb4
commit
cbc2b88f47
12 changed files with 4762 additions and 25 deletions
23
tests/Rng.test.js
Normal file
23
tests/Rng.test.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { Rng } from '../common/Rng'
|
||||
|
||||
test('random should give same results', () => {
|
||||
const rng = new Rng(1337)
|
||||
const rng2 = new Rng(1337)
|
||||
for (let i = 0; i < 100; i++) {
|
||||
expect(rng.random()).toBe(rng2.random())
|
||||
}
|
||||
})
|
||||
|
||||
test('should be serializable/deserializable', () => {
|
||||
const rng = new Rng(1337)
|
||||
// do some randoms, so that it doesnt start at 'after init'
|
||||
for (let i = 0; i < 100; i++) {
|
||||
rng.random()
|
||||
}
|
||||
|
||||
const rng2 = Rng.unserialize(Rng.serialize(rng))
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
expect(rng.random()).toBe(rng2.random())
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue