]> gitweb.factorcode.org Git - factor.git/blob - basis/combinators/random/random-tests.factor
basis: Cleaning up tests using lists and IN: forms.
[factor.git] / basis / combinators / random / random-tests.factor
1 ! Copyright (C) 2010 Jon Harper.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators.random combinators.random.private tools.test ;
4
5 { 1 } [ 1 [ 1 ] [ 2 ] ifp ] unit-test
6 { 2 } [ 0 [ 1 ] [ 2 ] ifp ] unit-test
7
8 { 3 }
9 [ { { 0 [ 1 ] }
10     { 0 [ 2 ] }
11     { 1 [ 3 ] }
12     [ 4 ]
13   } casep ] unit-test
14
15 { 4 }
16 [ { { 0 [ 1 ] }
17     { 0 [ 2 ] }
18     { 0 [ 3 ] }
19     [ 4 ]
20   } casep ] unit-test
21
22 { 1 1 } [ 1 {
23     { 1 [ 1 ] }
24     { 0 [ 2 ] }
25     { 0 [ 3 ] }
26     [ 4 ]
27     } casep ] unit-test
28
29 { 1 4 } [ 1 {
30     { 0 [ 1 ] }
31     { 0 [ 2 ] }
32     { 0 [ 3 ] }
33     [ 4 ]
34     } casep ] unit-test
35
36 { 2 } [ 0.7 {
37     { 0.3 [ 1 ] }
38     { 0.5 [ 2 ] }
39     [ 2 ] } (casep) ] unit-test
40
41 { { { 1/3 [ 1 ] }
42     { 1/3 [ 2 ] }
43     { 1/3 [ 3 ] } } }
44 [ { [ 1 ] [ 2 ] [ 3 ] } call-random>casep ] unit-test
45
46 { { { 1/2 [ 1 ] }
47     { 1/4 [ 2 ] }
48     { 1/4 [ 3 ] } } }
49 [ { { 1/2 [ 1 ] }
50     { 1/2 [ 2 ] }
51     { 1 [ 3 ] } } direct>conditional ] unit-test
52
53 { { { 1/2 [ 1 ] }
54     { 1/4 [ 2 ] }
55     { [ 3 ] } } }
56 [ { { 1/2 [ 1 ] }
57     { 1/2 [ 2 ] }
58     { [ 3 ] } } direct>conditional ] unit-test
59
60 { f } [ { { 0.6 [ 1 ] }
61   { 0.6 [ 2 ] } } good-probabilities? ] unit-test
62 { f } [ { { 0.3 [ 1 ] }
63   { 0.6 [ 2 ] } } good-probabilities? ] unit-test
64 { f } [ { { -0.6 [ 1 ] }
65   { 1.4 [ 2 ] } } good-probabilities? ] unit-test
66 { f } [ { { -0.6 [ 1 ] }
67   [ 2 ] } good-probabilities? ] unit-test
68 { t } [ { { 0.6 [ 1 ] }
69   [ 2 ] } good-probabilities? ] unit-test
70 { t } [ { { 0.6 [ 1 ] }
71   { 0.4 [ 2 ] } } good-probabilities? ] unit-test