test: vector.

* src/test/gc.c (test_vector): New function.
(main): Call it.
(print_arena): New function.
(test_gc): Call it.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-27 15:24:42 +01:00
parent 3bb4b05666
commit 47f797031f
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 26 additions and 6 deletions

View File

@ -60,18 +60,23 @@ test_setup ()
g_free = cell_f; g_free = cell_f;
} }
void
print_arena (long length)
{
SCM v = cell_arena;
TYPE (v) = TVECTOR;
LENGTH (v) = length;
eputs ("arena["); eputs (ntoab (g_cells, 16, 0)); eputs ("]: "); write_ (v); eputs ("\n");
}
void void
test_gc (char const *name) test_gc (char const *name)
{ {
eputs ("TEST: "); eputs (name); eputs ("\n"); eputs ("TEST: "); eputs (name); eputs ("\n");
SCM v = cell_arena; print_arena (gc_free () - 1);
TYPE (v) = TVECTOR;
LENGTH (v) = gc_free () - 1;
eputs ("arena["); eputs (ntoab (g_cells, 16, 0)); eputs ("]: "); write_ (v); eputs ("\n");
gc_stats_ ("0"); gc_stats_ ("0");
gc_ (); gc_ ();
v = cell_arena; print_arena (gc_free () - 1);
eputs ("arena["); eputs (ntoab (g_cells, 16, 0)); eputs ("]: "); write_ (v); eputs ("\n");
gc_stats_ ("1"); gc_stats_ ("1");
eputs ("\n"); eputs ("\n");
} }
@ -130,6 +135,20 @@ test_string ()
test_gc ("string"); test_gc ("string");
} }
void
test_vector ()
{
test_setup ();
SCM v = make_vector_ (4, cell_zero);
SCM one = make_number (1);
SCM two = make_number (2);
vector_set_x_ (v, 1, one);
vector_set_x_ (v, 2, two);
g_free = g_symbol_max + M2_CELL_SIZE;
test_gc ("vector");
}
int int
main (int argc, char **argv, char **envp) main (int argc, char **argv, char **envp)
{ {
@ -155,6 +174,7 @@ main (int argc, char **argv, char **envp)
test_cons (); test_cons ();
test_list (); test_list ();
test_string (); test_string ();
test_vector ();
return 0; return 0;
} }