From a0491606bc308a7e122589075e61c2b6829ace2b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 14 Feb 2009 14:04:54 -0600 Subject: [PATCH] fix { } randomize, more unit tests --- basis/random/random-tests.factor | 6 ++++++ basis/random/random.factor | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/basis/random/random-tests.factor b/basis/random/random-tests.factor index 160a4fced1..60cdee98ed 100644 --- a/basis/random/random-tests.factor +++ b/basis/random/random-tests.factor @@ -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 diff --git a/basis/random/random.factor b/basis/random/random.factor index 5befee7339..9564e0a268 100755 --- a/basis/random/random.factor +++ b/basis/random/random.factor @@ -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>