fix { } randomize, more unit tests

db4
Doug Coleman 2009-02-14 14:04:54 -06:00
parent 1418a67cc6
commit a0491606bc
2 changed files with 8 additions and 2 deletions

View File

@ -18,6 +18,12 @@ IN: random.tests
[ f ] [ 0 random ] unit-test
[ 0 ] [ { } >randomize-range length ] unit-test
[ 0 ] [ { 1 } >randomize-range length ] unit-test
[ { } ] [ { } randomize ] unit-test
[ { 1 } ] [ { 1 } randomize ] unit-test
[ f ]
[ 100 [ { 0 1 } random ] replicate all-equal? ] unit-test

View File

@ -43,8 +43,8 @@ M: f random-32* ( obj -- * ) no-random-number-generator ;
[ random-bytes >byte-array byte-array>bignum ]
[ 3 shift 2^ ] bi / * >integer ;
: >randomize-range ( seq -- range )
length 1+ 2 (a,b] ; inline
: >randomize-range ( seq -- range/iota )
length dup 2 < [ drop 0 iota ] [ 1+ 2 (a,b] ] if ;
PRIVATE>