Finish value constructors TODO, start container constructors TODO
This commit is contained in:
13
alisp.org
13
alisp.org
@@ -42,15 +42,13 @@ perspective.
|
|||||||
Should we capitalise symbols? This way, we limit the symbol table's
|
Should we capitalise symbols? This way, we limit the symbol table's
|
||||||
possible options a bit (potentially we could design a better hashing
|
possible options a bit (potentially we could design a better hashing
|
||||||
algorithm?) and it would be kinda like an actual Lisp.
|
algorithm?) and it would be kinda like an actual Lisp.
|
||||||
** DONE Test value constructors and destructors :test:
|
** WIP Test containers constructors and destructors :test:
|
||||||
Test if ~make_int~ works with ~as_int,~ ~intern~ with ~as_sym~.
|
|
||||||
Latter will require a symbol table.
|
|
||||||
** TODO Test containers constructors and destructors :test:
|
|
||||||
Test if ~make_vec~ works with ~as_vec~, ~cons~ with ~as_cons~ AND
|
Test if ~make_vec~ works with ~as_vec~, ~cons~ with ~as_cons~ AND
|
||||||
~CAR~, ~CDR~.
|
~CAR~, ~CDR~.
|
||||||
|
|
||||||
We may need to think of effective ways to deal with NILs. Maybe make
|
We may need to think of effective ways to deal with NILs in ~car~ and
|
||||||
functions as well as the macros so I can choose between them?
|
~cdr~. Maybe make functions as well as the macros so I can choose
|
||||||
|
between them?
|
||||||
** TODO Test system registration of allocated units :test:
|
** TODO Test system registration of allocated units :test:
|
||||||
In particular, does clean up work as we expect? Do we have situations
|
In particular, does clean up work as we expect? Do we have situations
|
||||||
where we may double free or not clean up something we should've?
|
where we may double free or not clean up something we should've?
|
||||||
@@ -110,3 +108,6 @@ Latter approach time complexity:
|
|||||||
|
|
||||||
Former approach is better time complexity wise, but latter is way
|
Former approach is better time complexity wise, but latter is way
|
||||||
better in terms of simplicity of code. Must deliberate.
|
better in terms of simplicity of code. Must deliberate.
|
||||||
|
** DONE Test value constructors and destructors :test:
|
||||||
|
Test if ~make_int~ works with ~as_int,~ ~intern~ with ~as_sym~.
|
||||||
|
Latter will require a symbol table.
|
||||||
|
|||||||
46
main.c
46
main.c
@@ -44,6 +44,19 @@ char *words[] = {
|
|||||||
"euismod", "tellus", "id", "erat",
|
"euismod", "tellus", "id", "erat",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
char text[] =
|
||||||
|
"Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. "
|
||||||
|
"Etiam vel tortor sodales tellus ultricies commodo. Suspendisse potenti. "
|
||||||
|
"Aenean in sem ac leo mollis blandit. Donec neque quam, dignissim in, "
|
||||||
|
"mollis nec, sagittis eu, wisi. Phasellus lacus. Etiam laoreet quam sed "
|
||||||
|
"arcu. Phasellus at dui in ligula mollis ultricies. Integer placerat "
|
||||||
|
"tristique nisl. Praesent augue. Fusce commodo. Vestibulum convallis, "
|
||||||
|
"lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor "
|
||||||
|
"vitae lacus. Nullam libero mauris, consequat quis, varius et, dictum id, "
|
||||||
|
"arcu. Mauris mollis tincidunt felis. Aliquam feugiat tellus ut neque. "
|
||||||
|
"Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, "
|
||||||
|
"et dictum nunc justo sit amet elit.";
|
||||||
|
|
||||||
void vec_test(void)
|
void vec_test(void)
|
||||||
{
|
{
|
||||||
vec_t vec = {0};
|
vec_t vec = {0};
|
||||||
@@ -111,6 +124,37 @@ void intern_test(void)
|
|||||||
sys_cleanup(&system);
|
sys_cleanup(&system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void make_vec_test(void)
|
||||||
|
{
|
||||||
|
struct Test
|
||||||
|
{
|
||||||
|
u64 start, size;
|
||||||
|
} tests[] = {
|
||||||
|
{0, 16},
|
||||||
|
{0, 32},
|
||||||
|
{32, 64},
|
||||||
|
{0, ARRSIZE(text)},
|
||||||
|
};
|
||||||
|
|
||||||
|
sys_t system = {0};
|
||||||
|
sys_init(&system);
|
||||||
|
|
||||||
|
for (u64 i = 0; i < ARRSIZE(tests); ++i)
|
||||||
|
{
|
||||||
|
struct Test test = tests[i];
|
||||||
|
// Always initialise below what we expect
|
||||||
|
lisp_t *lvec = make_vec(&system, test.size / 2);
|
||||||
|
vec_t *vec = as_vec(lvec);
|
||||||
|
printf("[make_vec_test]: %p -> %p[%lu/%lu] -> ", lvec, vec, vec->size,
|
||||||
|
vec->capacity);
|
||||||
|
vec_append(vec, text + test.start, test.size);
|
||||||
|
printf("[%lu/%lu] -> ", vec->size, vec->capacity);
|
||||||
|
printf("`%.*s`\n", (int)vec->size, (char *)vec_data(vec));
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_cleanup(&system);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
vec_test();
|
vec_test();
|
||||||
@@ -120,5 +164,7 @@ int main(void)
|
|||||||
make_int_test();
|
make_int_test();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
intern_test();
|
intern_test();
|
||||||
|
printf("\n");
|
||||||
|
make_vec_test();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user