Debian Codegraph @

terps/tads/tads3/test/data/shuffle2.t

raw
1 /*
2 * Test of the <<one of>> list class. This generates some picks for each
3 * named <<one of>> type used in the compiler.
4 */
5
6 #include <tads.h>
7
8
9
10 main(args)
11 {
12 test('purely at random', 'rand');
13 test('then purely at random', 'seq,rand');
14 test('at random', 'rand-norpt');
15 test('then at random', 'seq,rand-norpt');
16 test('sticky random', 'rand,stop');
17 test('as decreasingly likely outcomes', 'rand-wt');
18 test('shuffled', 'shuffle');
19 test('then shuffled', 'seq,shuffle');
20 test('cycling', 'seq');
21 test('stopping', 'seq,stop');
22 test('half shuffled', 'shuffle2');
23 }
24
25 test(name, attr)
26 {
27 local lst = new OneOfIndexGen();
28 lst.numItems = 10;
29 lst.listAttrs = attr;
30
31 "<<name>>: ";
32 local trials = 50;
33 for (local i in 1..trials)
34 "<<lst.getNextIndex()>><<if i < trials>>, ";
35 "\b";
36 }