-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-gen.py
67 lines (54 loc) · 878 Bytes
/
test-gen.py
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
#!py3
from string import Template
template_str = """
example_test$index :: () -> int
{
return fact_rec$index( 10 ) == fact_iter$index( 10 );
}
IntOrPtr$index :: struct
{
i: int;
p: *int;
}
f$index :: ()
{
u: IntOrPtr$index = { 42, 42 as *int };
u.i = 0;
u.p = 0 as *int;
}
iter$index: int;
Vector$index :: struct
{
x, y: int;
}
fact_iter$index :: ( n: int ) -> int
{
r := 1;
for( i: 2..n )
{
r *= i;
}
return r;
}
fact_rec$index :: ( n: int ) -> int
{
if( n == 0 )
{
return 1;
}
else
{
return n * fact_rec$index( n - 1 );
}
}
n$index :: 1 + sizeof(p$index);
p$index: *T$index;
T$index :: struct
{
a: [n$index]int;
}
"""
if __name__ == '__main__':
template = Template(template_str)
for i in range(32 * 1024):
print(template.substitute({'index': i}))