aboutsummaryrefslogtreecommitdiff
path: root/main.c
blob: c59984fba6ab24f159c9e904b595c53b3e69b7a8 (plain) (blame)
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
// This is the test unit, not the actual code.

#include "moonshine.h"

const enum { test_datatype, test_linkedlist } current_test = test_linkedlist;

int main() {
    if (current_test == test_datatype) {
        datatype(binarytree, ((leaf, int), (node, binarytree *, int, binarytree *) ));
        const auto tree = instance(binarytree, leaf, 3);

        print(&tree);

        match(tree) {
            of(leaf, v) print("Leafy ", v);
            of(node, _, v, _) print("Nodey ", v);
            other() print("Idk man");
        }
    } else if (current_test == test_linkedlist) {
        const auto ll = create_linkedlist();

        for (u8 i = 0; i < 100; i++) push_linkedlist(ll, (var) i);

        print((u8) index_to_ptr(ll, 12)->data);
    }

    else {
        print("Unknown test.");
    }

    return 0;
}