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