-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_test.py
More file actions
53 lines (42 loc) · 806 Bytes
/
generate_test.py
File metadata and controls
53 lines (42 loc) · 806 Bytes
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
template = """
func example_test(?)(): int {
return fact_rec(?)(10) == fact_iter(?)(10);
}
union IntOrPtr(?) {
i: int;
p: int*;
}
// func f(?)() {
// u1 := IntOrPtr(?){i = 42};
// u2 := IntOrPtr(?){p = (:int*)42};
// u1.i = 0;
// u2.p = (:int*)0;
// }
var i(?): int;
struct Vector(?) {
x: int;
y: int;
}
func fact_iter(?)(n: int): int {
r := 1;
for (i := 2; i <= n; i++) {
r *= i;
}
return r;
}
func fact_rec(?)(n: int): int {
if (n == 0) {
return 1;
} else {
return n * fact_rec(?)(n-1);
}
}
const n(?) = 1 + sizeof(p(?));
var p(?): T(?)*;
struct T(?) {
a: int[n(?)];
}
"""
print("func main(argc: int, argv: char**): int { return 0; }")
for i in range(4 * 1024):
print(template.replace("(?)", str(i)))