factor/library/test/random.factor

31 lines
475 B
Factor
Raw Normal View History

2004-07-16 02:26:21 -04:00
IN: scratchpad
USE: arithmetic
USE: kernel
USE: lists
USE: logic
USE: namespaces
USE: random
USE: stack
2004-07-16 02:26:21 -04:00
USE: test
[ t ]
[ [ 1 2 3 ] random-element number? ]
unit-test
2004-07-16 02:26:21 -04:00
[
[ 10 | t ]
[ 20 | f ]
[ 30 | "monkey" ]
] "random-pairs" set
[ f ]
[
"random-pairs" get
random-element* [ t f "monkey" ] contains? not
] unit-test
: check-random-int ( min max -- )
2dup random-int -rot between? assert ;
2004-07-16 02:26:21 -04:00
[ ] [ 100 [ -12 674 check-random-int ] times ] unit-test