forked from kevinlawler/kona
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkapi-test.c
110 lines (87 loc) · 1.76 KB
/
kapi-test.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
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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "kona.h"
Z int pass, fail;
extern K KTREE;
#define tst(e) if(e){pass++;}else{fprintf(stderr, "Failed:%s\n", #e); fail++;}
#define TEST(i,x,f) do { {i;} tst(x); {f;}} while(0)
int
main(int argc, char** argv)
{
F pi = atan(1.0)*4;
K a = gi(2);
K b = gi(3);
K c = gi(4);
K* v;
cd(ksk("",0));
tst(Ki(a)==2);
tst(Ki(b) + 1 == Ki(c));
cd(a); cd(b); cd(c);
b = gf(1.0); c = gf(2);
tst(Kf(b) + 1 == Kf(c));
cd(b); cd(c);
a = gs(sp("foo"));
b = ksk("`foo", 0);
tst(Ks(a) == Ks(b));
cd(a); cd(b);
a = ksk("2 + 3", 0);
tst(Ki(a) == 5);
cd(a);
a = ksk("_ci 65", 0);
tst(Kc(a) == 'A');
// XXX this should return type 1 uniform vector
a=gnk(3,gi(11),gi(22),gi(33));
tst(a->t == 0);
v = (K*)a->k;
tst(Ki(v[0])+Ki(v[1])==Ki(v[2]));
cd(a);
{
b = gsk("pi",gf(pi));
kap(&KTREE, &b);
a = X(".pi");
tst(Kf(a) == pi);
cd(a);
}
{
K dir = gtn(5,0);
K t;
t = gsk("x",gi(1)); kap(&dir, &t);
t = gsk("y",gi(2)); kap(&dir, &t);
t = gsk("z",dir); kap(&KTREE, &t);
a = X(".z.x");
tst(Ki(a) == 1);
cd(a);
a = X(".z.y");
tst(Ki(a) == 2);
cd(a);
}
{
I i;
K d = gtn(5,0);
K c0 = gtn(0,0);
K c1 = gtn(-1,0);
K t0, t1, e;
t0 = gsk("a", c0); kap(&d,&t0);
t1 = gsk("b", c1); kap(&d,&t1);
e = gp("hello1"); kap(&c0,&e);
e = gp("hello2"); kap(&c0,&e);
KK(KK(d)[0])[1] = c0;
i = 1; kap(&KK(KK(d)[1])[1], &i);
i = 2; kap(&KK(KK(d)[1])[1], &i);
//i = 1; kap(&c1, &i);
//i = 2; kap(&c1, &i);
//KK(KK(d)[1])[1] = c1;
show(d);
}
//b = ksk("+/", a);
//tst(Ki(b) == 66);
//argc--;argv++;
//DO(i, argc, {a=ksk(argv[i], 0);
//ksk("`0:,/$!10;`0:,\"\n\"", 0);
fprintf(stderr, "Pass:%4d, fail:%4d\n", pass, fail);
if (argc > 1 && strcmp(argv[1], "-i") == 0) {
boilerplate();
attend();
}
}