Interaction Trees in Zig and simple benchmarks
This commit is contained in:
@@ -51,6 +51,68 @@ int main(void) {
|
||||
}
|
||||
printf("PASS: kernel loaded (root=%u)\n", kernel_root);
|
||||
|
||||
/* Test: tree inspection primitives */
|
||||
uint32_t l = arb_leaf(ctx);
|
||||
uint32_t s = arb_stem(ctx, l);
|
||||
uint32_t f = arb_fork(ctx, s, l);
|
||||
uint32_t a = arb_app(ctx, f, s);
|
||||
|
||||
if (!arb_is_leaf(ctx, l)) {
|
||||
fprintf(stderr, "FAIL: is_leaf on leaf\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
if (arb_is_leaf(ctx, s)) {
|
||||
fprintf(stderr, "FAIL: is_leaf on stem should be false\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
if (!arb_is_stem(ctx, s)) {
|
||||
fprintf(stderr, "FAIL: is_stem on stem\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
if (!arb_is_fork(ctx, f)) {
|
||||
fprintf(stderr, "FAIL: is_fork on fork\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
if (!arb_is_app(ctx, a)) {
|
||||
fprintf(stderr, "FAIL: is_app on app\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t child;
|
||||
if (!arb_get_stem_child(ctx, s, &child) || child != l) {
|
||||
fprintf(stderr, "FAIL: get_stem_child\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t left, right;
|
||||
if (!arb_get_fork_children(ctx, f, &left, &right) || left != s || right != l) {
|
||||
fprintf(stderr, "FAIL: get_fork_children\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t func, arg;
|
||||
if (!arb_get_app_func_arg(ctx, a, &func, &arg) || func != f || arg != s) {
|
||||
fprintf(stderr, "FAIL: get_app_func_arg\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Invalid index should return 0 */
|
||||
if (arb_is_leaf(ctx, 999999)) {
|
||||
fprintf(stderr, "FAIL: is_leaf on invalid index should be false\n");
|
||||
arboricx_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("PASS: tree inspection primitives\n");
|
||||
|
||||
arboricx_free(ctx);
|
||||
printf("\nAll C ABI tests passed.\n");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user