// vim: nowrap #include #include #include #include #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]]) [((0 [[0]]) [((0 [[0]]) [((0 [[0]]) [((0 [[1]]) [((0 [[1]]) [((0 [[0]]) [[0]])])])])])])])])]) [((0 [((0 [[0]]) [((0 [[1]]) [((0 [[0]]) [((0 [[0]]) [((0 [[0]]) [((0 [[1]]) [((0 [[1]]) [((0 [[0]]) [[0]])])])])])])])])]) [[0]])])]))"); // 1-1-1-2-6-1-2-6-1-3-2-5-6-2-6-2-6-1-1-1-2-6-1-1-3-3-1-1-2-6-1-2-6-1-3-2-5-6-2-6-1-1-1-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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 #include #include #include 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