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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// vim: nowrap
#include <stdio.h>
#include <parse.h>
#include <term.h>
#include <reducer.h>
#ifndef TEST
int main(void)
{
struct term *term = parse(
"((([([(1 [((1 1) 0)])] [(1 [((1 1) 0)])])] [[[((([((0 [[[[[0]]]]]) [[1]])] 0) [[0]]) ((([((((0 [[1]]) [[[0]]]) [[[0]]]) [0])] 1) [[0]]) (([[[((0 2) 1)]]] ([(0 [[1]])] 0)) ((2 ([([(0 [[0]])] ((((0 (([[[((0 2) 1)]]] [[[[3]]]]) [[[[(2 3)]]]])) [(0 [[(([[[((0 2) 1)]]] ([[[[[(2 ((((4 3) 2) 1) 0))]]]]] 1)) ([[[[[(1 ((((4 3) 2) 1) 0))]]]]] 0))]])]) [(0 [[(([[[((0 2) 1)]]] ([[[[[(1 ((((4 3) 2) 1) 0))]]]]] 1)) ([[[[[(0 ((((4 3) 2) 1) 0))]]]]] 1))]])]) [(0 [[(([[[((0 2) 1)]]] ([[[[[(0 ((((4 3) 2) 1) 0))]]]]] 1)) ([[[[[(2 ((((4 3) 2) 1) 0))]]]]] 1))]])]))] 1)) ([(0 [[0]])] 0)))))]]]) [[[[(0 (2 (1 3)))]]]]) (([([(1 [((1 1) 0)])] [(1 [((1 1) 0)])])] [[((([([(1 [((1 1) 0)])] [(1 [((1 1) 0)])])] [[[((([((0 [[[[[0]]]]]) [[1]])] 1) 0) (([[[((0 2) 1)]]] ([(0 [[1]])] 1)) ((2 ([(0 [[0]])] 1)) 0)))]]]) 0) (1 0))]]) [((0 [((0 [[1]]) [((0 [[0]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2-6-2-6-1-3-2-5-6-1-3-1-1-1-1-3-3-3-1-2-6-2-5-5-5-6-2-6-2-6-2-6-1-3-3-2-5-5-6-1-3-1-1-1-1-3-3-3-1-2-6-2-5-5-5-6-2-6-2-6-2-6-1-3-4-5-6-1-3-1-1-1-1-3-3-3-2-5-5-5-6-2-6-2-6-2-6-3-3-3-3-1-1-2-6-2-6-2-5-5-5-5-5-6-1-1-3-2-5-6-2-6-1-1-2-6-2-6-2-5-6-1-1-3-2-5-6-2-6-1-1-2-6-2-6-2-5-6-1-1-3-2-5-6-2-6-1-1-2-6-2-6-2-5-6-1-1-3-2-5-6-2-6-3-3-1-2-6-2-5-5-5-5-5-6-2-6-2-6-2-6-1-3-2-5-6-3-1-1-1-1-3-3-3-1-2-6-2-5-5-5-6-2-6-2-6-2-6-1-3-4-5-6-3-1-1-1-1-3-3-3-1-2-6-2-5-5-5-6-2-6-2-6-2-6-1-3-4-5-6-3-1-1-1-1-3-3-3-2-5-5-5-6-2-6-2-6-2-6-3-3-3-3-2-5-5-5-5-5-5-5-6-2-6-3-2-5-5-5-7-2-7-4-11-5-11-5-10-11-5-10-11-5-10-11-5-10-11-5-10-11-5-10-11-5
/* print_scheme(term); */
printf("\nReduced:\n");
reduce(term);
/* print_term(reduced); */
printf("\n");
free_term(term);
/* free_term(reduced); */
return 0;
}
#else
#define TESTS 2
#define TESTDIR "./tests/"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>
static char *read_file(const char *path)
{
FILE *f = fopen(path, "rb");
if (!f) {
fprintf(stderr, "Can't open file %s: %s\n", path,
strerror(errno));
return 0;
}
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
char *string = malloc(fsize + 1);
int ret = fread(string, fsize, 1, f);
fclose(f);
if (ret != 1) {
fprintf(stderr, "Can't read file %s: %s\n", path,
strerror(errno));
return 0;
}
string[fsize] = 0;
return string;
}
int main(void)
{
struct {
struct term *in;
struct term *res;
struct term *red;
char *trans;
struct {
int alpha;
int trans;
} equivalency;
} tests[TESTS] = { 0 };
char in_template[] = TESTDIR "x.in";
char red_template[] = TESTDIR "x.red";
char trans_template[] = TESTDIR "x.trans";
int offset = strlen(TESTDIR);
for (int i = 0; i < TESTS; i++) {
char ch = '0' + i + 1;
in_template[offset] = ch;
red_template[offset] = ch;
trans_template[offset] = ch;
tests[i].trans = read_file(trans_template);
char *in = read_file(in_template);
tests[i].in = parse(in);
free(in);
char *red = read_file(red_template);
tests[i].red = parse(red);
to_bruijn(tests[i].red);
free(red);
}
clock_t begin = clock();
for (int i = 0; i < TESTS; i++)
tests[i].res = reduce(tests[i].in);
clock_t end = clock();
for (int i = 0; i < TESTS; i++) {
to_bruijn(tests[i].res);
tests[i].equivalency.alpha =
alpha_equivalency(tests[i].res, tests[i].red);
tests[i].equivalency.trans = 1; // TODO
}
printf("=== SUMMARY ===\n");
printf("Reduced tests in %.5fs\n",
(double)(end - begin) / CLOCKS_PER_SEC);
for (int i = 0; i < TESTS; i++) {
if (!tests[i].equivalency.alpha ||
!tests[i].equivalency.trans) {
printf("Test %d: [failed]\n\talpha-equivalency: %d\n\ttrans-equivalency: %d\n",
i, tests[i].equivalency.alpha,
tests[i].equivalency.trans);
}
}
}
#endif
|