-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestrandclassarr2.d
75 lines (68 loc) · 1.21 KB
/
testrandclassarr2.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import esdl.rand;
@rand(false)
class Zoo {
}
class Foo {
mixin randomization;
private @rand uint frop;
private @rand uint paaa;
private @rand uint maaa;
private @rand ubyte free;
constraint! q{
frop > 50;
paaa + frop + maaa == 100;
paaa < 100;
maaa < 100;
} gt50;
public:
void display() {
import std.stdio;
writeln("frop is: ", frop, " paaa is: ", paaa,
" maaa is: ", maaa, " free is: ", free);
}
}
class Bar {
mixin randomization;
this() {
foos.length = 4;
foreach (i, ref foo1; foos) {
foo1.length = 4;
foreach (ref foo2; foo1) {
foo2 = new Foo;
}
}
}
Zoo zoo;
@rand Foo[][] foos;
void preRandomize() {
frop++;
}
int frop = 52;
constraint!q{
// foos.length == 4;
// foos.length > 2;
foreach (i, foo1; foos) {
foreach (j, foo2; foo1) {
foo2.frop == frop + i * j;
}
}
} frop_cst;
void display() {
foreach (i, foo1; foos) {
foreach (j, foo2; foo1) {
import std.stdio;
writefln("frop: %d, i: %d, j: %d", frop, i, j);
foo2.display();
}
}
}
}
void main()
{
import std.stdio;
Bar bar = new Bar();
for (size_t i=0; i!=10; ++i) {
bar.randomize();
bar.display();
}
}