1 USING: kernel math random namespaces make
2 random.mersenne-twister sequences tools.test math.order ;
3 IN: random.mersenne-twister.tests
5 : check-random ( max -- ? )
6 [ random 0 ] keep between? ;
8 [ t ] [ 100 [ drop 674 check-random ] all? ] unit-test
11 100 [ 100 random ] replicate ;
13 : test-rng ( seed quot -- )
14 [ <mersenne-twister> ] dip with-random ;
16 [ f ] [ 1234 [ randoms randoms = ] test-rng ] unit-test
19 0 [ 1000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
23 0 [ 10000 [ drop random-generator get random-32* drop ] each random-generator get random-32* ] test-rng
27 [ 3 ] [ 101 [ 3 random-bytes length ] test-rng ] unit-test
28 [ 33 ] [ 101 [ 33 random-bytes length ] test-rng ] unit-test
29 [ t ] [ 101 [ 100 random-bits log2 90 > ] test-rng ] unit-test