-
Notifications
You must be signed in to change notification settings - Fork 0
/
test5.c
64 lines (57 loc) · 1.36 KB
/
test5.c
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
/*
* test5.c - alpha conversion test
*
* $Id: test5.c,v 1.1 2002/05/01 09:38:01 tominaga Exp $
*/
#include <stdio.h>
#include "lambda.h"
#define NELEMS(a) (sizeof(a)/sizeof(a[0]))
struct testcase {
char *mstr;
Var var;
char *nstr;
} testcases[] = {
{ "1", 1, "2" },
{ "1", 1, "1" },
{ "2", 2, "3" },
{ "2", 1, "3" },
{ "1", 2, "5" },
{ "1", 1, "(10 20)" },
{ "2", 1, "(10 20)" },
{ "5", 5, "(5 10)" },
{ "(1 2)", 2, "(3 4)" },
{ "(2 2)", 2, "(3 4)" },
{ "(L 1.2)", 2, "(3 4)" },
{ "(L 1.2)", 1, "(3 4)" },
{ "(L 2.1)", 1, "(3 4)" },
{ "(L 1.1)", 1, "(3 4)" },
{ "(L 1.(2 3))", 3, "(4 5)" },
{ "(L 1.(2 3))", 3, "(3 3)" },
{ "(L 1.(L 2.1))", 1, "(3 3)" },
{ "((L 1.(L 2.1)) (L 2.(L 1.2)))", 1, "(3 3)" },
{ "((L 1.(L 2.1)) (L 2.(L 1.2)))", 2, "(3 3)" },
{ "((L 1.(L 2.1)) (L 2.(L 2.1)))", 1, "(3 3)" },
};
int
main() {
int i;
struct testcase *p;
Lexp m, n, l;
Var v;
initpool();
for (i = 0, p = testcases; i < NELEMS(testcases); i++, p++) {
printf("case %d: m=\"%s\", v=%ld, n=\"%s\"\n", i, p->mstr, p->var, p->nstr);
m = str2lexp(p->mstr);
printf(" created lexp for m: ");
printlexp(m);
n = str2lexp(p->nstr);
printf(" created lexp for n: ");
printlexp(n);
v = p->var;
l = alpha(m, v, n);
printf(" after alpha conversion: ");
printlexp(l);
}
return 0;
}
/* [EOF] */