Commit 3ef59aacf09eca3798296c4d51bad389e8a5047a

Thomas de Grivel 2022-11-07T01:01:55

facts_test, eval wip

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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
diff --git a/README.md b/README.md
index 14a6cbd..664ca54 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # C3 v0.1
 
 C3 is a programming language, inspired by C89, Elixir and Common Lisp.
-It aims to replace C89 with an Elixir syntax.
+It aims to better C89 with an Elixir syntax.
 
 ```
 defmodule C3 do
diff --git a/libc3/env.c b/libc3/env.c
new file mode 100644
index 0000000..d0affaa
--- /dev/null
+++ b/libc3/env.c
@@ -0,0 +1,32 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include "env.h"
+#include "error_handler.h"
+#include "frame.h"
+
+s_env * env_init (s_env *env)
+{
+  assert(env);
+  env->frame = NULL;
+  env->error_handler = NULL;
+  return env;
+}
+
+void env_clean (s_env *env)
+{
+  assert(env);
+  frame_delete_all(env->frame);
+  error_handler_delete_all(env->error_handler);
+}
diff --git a/libc3/env.h b/libc3/env.h
index ead8486..6dcc6a2 100644
--- a/libc3/env.h
+++ b/libc3/env.h
@@ -19,4 +19,4 @@
 s_env * env_init (s_env *env);
 void    env_clean (s_env *env);
 
-#endif /* C3_H */
+#endif /* ENV_H */
diff --git a/libc3/error_handler.h b/libc3/error_handler.h
new file mode 100644
index 0000000..0cf95d1
--- /dev/null
+++ b/libc3/error_handler.h
@@ -0,0 +1,31 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef ERROR_HANDLER_H
+#define ERROR_HANDLER_H
+
+#include "types.h"
+
+/* stack-allocation compatible functions */
+void              error_handler_clean (s_error_handler *error_handler);
+s_error_handler * error_handler_init (s_error_handler *error_handler,
+                                      s_error_handler *next);
+
+/* constructors */
+s_error_handler * error_handler_new (s_error_handler *next);
+
+/* destructors */
+void error_handler_delete (s_error_handler *error_handler);
+void error_handler_delete_all (s_error_handler *error_handler);
+
+#endif /* ERROR_HANDLER_H */
diff --git a/libc3/eval.h b/libc3/eval.h
new file mode 100644
index 0000000..169ccf0
--- /dev/null
+++ b/libc3/eval.h
@@ -0,0 +1,21 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef EVAL_H
+#define EVAL_H
+
+#include "types.h"
+
+s_tag * eval_tag (s_env *env, s_tag *tag);
+
+#endif /* EVAL_H */
diff --git a/libc3/facts.c b/libc3/facts.c
index f4f7716..37fe262 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -248,6 +248,8 @@ e_bool facts_remove_fact (s_facts *facts, const s_fact *fact)
   assert(fact);
   found = facts_find_fact(facts, fact);
   if (found) {
+    if (facts->log)
+      facts_log_remove(facts->log, found);
     skiplist_remove__fact(facts->index_spo, found);
     skiplist_remove__fact(facts->index_pos, found);
     skiplist_remove__fact(facts->index_osp, found);
diff --git a/libc3/frame.c b/libc3/frame.c
new file mode 100644
index 0000000..903ebbf
--- /dev/null
+++ b/libc3/frame.c
@@ -0,0 +1,56 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include <assert.h>
+#include <err.h>
+#include <stdlib.h>
+#include "frame.h"
+#include "list.h"
+
+void frame_clean (s_frame *frame)
+{
+  assert(frame);
+  list_delete(frame->bindings);
+}
+
+void frame_delete (s_frame *frame)
+{
+  if (frame)
+    frame_clean(frame);
+}
+
+void frame_delete_all (s_frame *frame)
+{
+  s_frame *next;
+  while (frame) {
+    next = frame->next;
+    frame_delete(frame);
+    frame = next;
+  }
+}
+
+s_frame * frame_init (s_frame *frame, s_frame *next)
+{
+  assert(frame);
+  frame->bindings = NULL;
+  frame->next = next;
+  return frame;
+}
+
+s_frame * frame_new (s_frame *next)
+{
+  s_frame *frame;
+  if (! (frame = malloc(sizeof(s_frame))))
+    errx(1, "frame_new: out of memory");
+  return frame_init(frame, next);
+}
diff --git a/libc3/frame.h b/libc3/frame.h
new file mode 100644
index 0000000..882fa0d
--- /dev/null
+++ b/libc3/frame.h
@@ -0,0 +1,30 @@
+/* c3
+ * Copyright 2022 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software granted
+ * the above copyright notice and this permission paragraph
+ * are included in all copies and substantial portions of this
+ * software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#ifndef FRAME_H
+#define FRAME_H
+
+#include "types.h"
+
+/* stack-allocation compatible functions */
+void      frame_clean (s_frame *frame);
+s_frame * frame_init (s_frame *frame, s_frame *next);
+
+/* constructors */
+s_frame * frame_new ();
+
+/* destructors */
+void frame_delete (s_frame *frame);
+void frame_delete_all (s_frame *frame);
+
+#endif /* FRAME_H */
diff --git a/libc3/types.h b/libc3/types.h
index 5dd6a90..8175c43 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -14,6 +14,7 @@
 #ifndef TYPES_H
 #define TYPES_H
 
+#include <setjmp.h>
 #include <stdio.h>
 #include "../libtommath/tommath.h"
 
@@ -307,4 +308,27 @@ typedef struct module {
   s_facts *facts;
 } s_module;
 
+/* error_handler */
+typedef struct error_handler s_error_handler;
+
+struct error_handler
+{
+  jmp_buf jmp_buf;
+  s_error_handler *next;
+};
+
+/* frame */
+typedef struct frame s_frame;
+
+struct frame {
+  s_list *bindings;
+  s_frame *next;
+};
+
+/* env */
+typedef struct env {
+  s_frame *frame;
+  s_error_handler *error_handler;
+} s_env;
+
 #endif /* TYPES_H */
diff --git a/test/fact_test.c b/test/fact_test.c
index eab833b..0321154 100644
--- a/test/fact_test.c
+++ b/test/fact_test.c
@@ -34,18 +34,6 @@ void fact_test ()
   fact_test_inspect();
 }
 
-s_fact * fact_test_1 (s_fact *fact, const s8 *tag)
-{
-  return fact_test_3(fact, tag, tag, tag);
-}
-
-s_fact * fact_test_3 (s_fact *fact, const s8 *subject,
-                      const s8 *predicate, const s8 *object)
-{
-  fact_test_clean(fact);
-  return fact_test_init_3(fact, subject, predicate, object);
-}
-
 s_fact * fact_test_clean (s_fact *fact)
 {
   assert(fact);
diff --git a/test/fact_test.h b/test/fact_test.h
index 1854962..67e437a 100644
--- a/test/fact_test.h
+++ b/test/fact_test.h
@@ -44,9 +44,6 @@
     }                                                                  \
   } while (0)
 
-s_fact * fact_test_1 (s_fact *fact, const s8 *tag);
-s_fact * fact_test_3 (s_fact *fact, const s8 *subject,
-                      const s8 *predicate, const s8 *object);
 s_fact * fact_test_clean (s_fact *fact);
 s_fact * fact_test_init_1 (s_fact *fact, const s8 *tag);
 s_fact * fact_test_init_3 (s_fact *fact, const s8 *subject,
diff --git a/test/facts_test.c b/test/facts_test.c
index dacbba7..5d46050 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -37,6 +37,7 @@ void facts_test ()
   facts_test_find();
   facts_test_log_add();
   facts_test_log_remove();
+  facts_test_dump();
 }
 
 void facts_test_add ()
@@ -296,7 +297,7 @@ void facts_test_log_remove ()
   BUF_INIT_ALLOCA(&log, 1024);
   fp = fopen("facts_test_log_remove.facts", "w");
   buf_file_open_w(&log, fp);
-  facts_init(&facts, NULL);
+  facts_init(&facts, &log);
   while (p[i]) {
     fact_test_init_1(fact + i, p[i]);
     facts_add_fact(&facts, fact + i);
@@ -306,6 +307,7 @@ void facts_test_log_remove ()
     facts_remove_fact(&facts, fact + i);
   }
   facts_clean(&facts);
+  buf_file_close(&log);
   fclose(fp);
   test_file_compare("facts_test_log_remove.facts",
                     "facts_test_log_remove.facts.expected");
diff --git a/test/facts_test_dump.facts b/test/facts_test_dump.facts
new file mode 100644
index 0000000..bebffb3
--- /dev/null
+++ b/test/facts_test_dump.facts
@@ -0,0 +1,23 @@
+add {a, a, a}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-4294967296, -4294967296, -4294967296}
+add {-65536, -65536, -65536}
+add {-256, -256, -256}
+add {-10, -10, -10}
+add {-1, -1, -1}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {"a", "a", "a"}
+add {A, A, A}
+add {:a, :a, :a}
+add {{a, b}, {a, b}, {a, b}}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
diff --git a/test/facts_test_dump.facts.expected b/test/facts_test_dump.facts.expected
new file mode 100644
index 0000000..bebffb3
--- /dev/null
+++ b/test/facts_test_dump.facts.expected
@@ -0,0 +1,23 @@
+add {a, a, a}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-4294967296, -4294967296, -4294967296}
+add {-65536, -65536, -65536}
+add {-256, -256, -256}
+add {-10, -10, -10}
+add {-1, -1, -1}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {"a", "a", "a"}
+add {A, A, A}
+add {:a, :a, :a}
+add {{a, b}, {a, b}, {a, b}}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
diff --git a/test/facts_test_log_add.facts b/test/facts_test_log_add.facts
new file mode 100644
index 0000000..5286f7a
--- /dev/null
+++ b/test/facts_test_log_add.facts
@@ -0,0 +1,23 @@
+add {"a", "a", "a"}
+add {:a, :a, :a}
+add {A, A, A}
+add {a, a, a}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+add {{a, b}, {a, b}, {a, b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-1, -1, -1}
+add {-10, -10, -10}
+add {-256, -256, -256}
+add {-65536, -65536, -65536}
+add {-4294967296, -4294967296, -4294967296}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
diff --git a/test/facts_test_log_add.facts.expected b/test/facts_test_log_add.facts.expected
index e69de29..5286f7a 100644
--- a/test/facts_test_log_add.facts.expected
+++ b/test/facts_test_log_add.facts.expected
@@ -0,0 +1,23 @@
+add {"a", "a", "a"}
+add {:a, :a, :a}
+add {A, A, A}
+add {a, a, a}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+add {{a, b}, {a, b}, {a, b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-1, -1, -1}
+add {-10, -10, -10}
+add {-256, -256, -256}
+add {-65536, -65536, -65536}
+add {-4294967296, -4294967296, -4294967296}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
diff --git a/test/facts_test_log_remove.facts b/test/facts_test_log_remove.facts
new file mode 100644
index 0000000..f96c838
--- /dev/null
+++ b/test/facts_test_log_remove.facts
@@ -0,0 +1,46 @@
+add {"a", "a", "a"}
+add {:a, :a, :a}
+add {A, A, A}
+add {a, a, a}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+add {{a, b}, {a, b}, {a, b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-1, -1, -1}
+add {-10, -10, -10}
+add {-256, -256, -256}
+add {-65536, -65536, -65536}
+add {-4294967296, -4294967296, -4294967296}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+remove {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+remove {-4294967296, -4294967296, -4294967296}
+remove {-65536, -65536, -65536}
+remove {-256, -256, -256}
+remove {-10, -10, -10}
+remove {-1, -1, -1}
+remove {18446744073709551616, 18446744073709551616, 18446744073709551616}
+remove {4294967296, 4294967296, 4294967296}
+remove {65536, 65536, 65536}
+remove {256, 256, 256}
+remove {10, 10, 10}
+remove {1, 1, 1}
+remove {0, 0, 0}
+remove {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+remove {{a, b}, {a, b}, {a, b}}
+remove {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+remove {{:a, :b}, {:a, :b}, {:a, :b}}
+remove {[[], []], [[], []], [[], []]}
+remove {[], [], []}
+remove {a, a, a}
+remove {A, A, A}
+remove {:a, :a, :a}
+remove {"a", "a", "a"}
diff --git a/test/facts_test_log_remove.facts.expected b/test/facts_test_log_remove.facts.expected
new file mode 100644
index 0000000..f96c838
--- /dev/null
+++ b/test/facts_test_log_remove.facts.expected
@@ -0,0 +1,46 @@
+add {"a", "a", "a"}
+add {:a, :a, :a}
+add {A, A, A}
+add {a, a, a}
+add {[], [], []}
+add {[[], []], [[], []], [[], []]}
+add {{:a, :b}, {:a, :b}, {:a, :b}}
+add {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+add {{a, b}, {a, b}, {a, b}}
+add {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+add {0, 0, 0}
+add {1, 1, 1}
+add {10, 10, 10}
+add {256, 256, 256}
+add {65536, 65536, 65536}
+add {4294967296, 4294967296, 4294967296}
+add {18446744073709551616, 18446744073709551616, 18446744073709551616}
+add {-1, -1, -1}
+add {-10, -10, -10}
+add {-256, -256, -256}
+add {-65536, -65536, -65536}
+add {-4294967296, -4294967296, -4294967296}
+add {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+remove {-18446744073709551616, -18446744073709551616, -18446744073709551616}
+remove {-4294967296, -4294967296, -4294967296}
+remove {-65536, -65536, -65536}
+remove {-256, -256, -256}
+remove {-10, -10, -10}
+remove {-1, -1, -1}
+remove {18446744073709551616, 18446744073709551616, 18446744073709551616}
+remove {4294967296, 4294967296, 4294967296}
+remove {65536, 65536, 65536}
+remove {256, 256, 256}
+remove {10, 10, 10}
+remove {1, 1, 1}
+remove {0, 0, 0}
+remove {{{a, b}, {c, d}}, {{a, b}, {c, d}}, {{a, b}, {c, d}}}
+remove {{a, b}, {a, b}, {a, b}}
+remove {{{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}, {{:a, :b}, {:c, :d}}}
+remove {{:a, :b}, {:a, :b}, {:a, :b}}
+remove {[[], []], [[], []], [[], []]}
+remove {[], [], []}
+remove {a, a, a}
+remove {A, A, A}
+remove {:a, :a, :a}
+remove {"a", "a", "a"}
diff --git a/test/test.c b/test/test.c
index 102201b..97a015b 100644
--- a/test/test.c
+++ b/test/test.c
@@ -33,7 +33,6 @@ const char **g_test_targets = {NULL};
 void test_context (const char *context)
 {
   g_test_context = context;
-  /* printf("test_context(%s)\n", context); */
 }
 
 int test_file_compare (const char *path_a, const char *path_b)
@@ -42,7 +41,7 @@ int test_file_compare (const char *path_a, const char *path_b)
   FILE *fp_b = fopen(path_b, "rb");
   char buf_a[1024];
   char buf_b[1024];
-  sw r;
+  int r;
   if (fp_a == fp_b)
     return 0;
   if (fp_a == NULL)
@@ -52,15 +51,20 @@ int test_file_compare (const char *path_a, const char *path_b)
   /* TODO: use fread and check how many bytes are read */
   while (fgets(buf_a, 1024, fp_a) != NULL) {
     if (fgets(buf_b, 1024, fp_b) == NULL) {
+      test_ko();
       return 1;
     }
     /* TODO: use memcmp for NUL bytes */
-    if ((r = strcmp(buf_a, buf_b)))
+    if ((r = strcmp(buf_a, buf_b))) {
+      test_ko();
       return r;
+    }
   }
   if (fgets(buf_b, 1024, fp_b) != NULL) {
+    test_ko();
     return -1;
   }
+  test_ok();
   return 0;
 }