30#define READER_TESTS(X) \
31 X("ir::reader::read_list_from_buffer", test_reader_read_list_from_buffer), \
32 X("ir::reader::malformed_utf8_in_string", test_reader_malformed_utf8_in_string), \
33 X("ir::reader::truncated_utf8_at_end", test_reader_truncated_utf8_at_end), \
34 X("ir::reader::trailing_whitespace_and_comment", test_reader_trailing_whitespace_and_comment), \
35 X("ir::reader::tree_has_no_error_on_success", test_reader_tree_has_no_error_on_success), \
36 X("ir::reader::location_len_over_64k", test_reader_location_len_over_64k)
43 .reading_context =
nullptr,
45 .buffer = (
const unsigned char *)src,
64 const char src[] =
"\"\x80\"";
81 const char src[] =
"foo \xE2";
93 const char *cases[] = {
"foo\n",
"(a b)\n\n",
"foo ; trailing comment",
" ",
""};
96 for (
size_t i = 0; i <
sizeof(cases) /
sizeof(cases[0]); i++) {
101 TEST_CHECK_(err ==
nullptr,
"case %zu: '%s'", i, cases[i]);
114 for (
int round = 0; round < 3; round++) {
116 const size_t n = 64 * 1024;
124 const char *src =
"(foo)";
127 .reading_context =
nullptr,
129 .buffer = (
const unsigned char *)src,
152 const size_t body = 70000;
155 memset(src + 1,
'a', body);
157 src[body + 2] =
'\0';
161 .reading_context =
nullptr,
163 .buffer = (
const unsigned char *)src,
188 auto sched = engine->scheduler;
190 const char *src =
"(foo bar baz)";
194 .reading_context =
nullptr,
196 .buffer = (
const unsigned char *)src,
#define TEST_CHECK_(cond,...)
array_list_maybe_element_t array_list_get(const array_list_t *al, array_list_index_t n)
Negative index is not supported.
#define RELEASE_CONTEXT(x)
#define ASSERT_NOT_NULL(x)
#define SHUTDOWN_ENGINE(mm, engine)
#define MAKE_ENGINE(mm, engine)
#define MAKE_CONTEXT(engine, x)
srn_context_t * srn_context_make(srn_engine_t *engine)
Make an empty context, by allocating a new memory block.
int srn_context_release(srn_context_t *ctx)
#define ALLOCN_OR_PANIC(ctx, T, N)
#define HAS_ERROR(x)
True when x – a value carrying an ERROR_HEADER – has an error attached.
srn_fiber_t * srn_fiber_spawn(srn_context_t *ctx, srn_fiber_entry_t entry, void *arg)
Make and schedule a fiber with every default, the engine's scheduler, the configured stack size,...
AI Generated (🤦) Fiber subsystem overview.
void * srn_fiber_result_t
What a fiber's entry produces, type-erased.
srn_fiber_result_t read_from_buffer(srn_context_t *ctx, void *arg)
A simple sexp reader to be used with textual IR.
static void test_reader_truncated_utf8_at_end()
static void test_reader_tree_has_no_error_on_success()
static void test_reader_trailing_whitespace_and_comment()
static void test_reader_malformed_utf8_in_string()
static void test_reader_read_list_from_buffer()
static srn_error_t * read_source(srn_context_t *ctx, const char *src, size_t len)
static void test_reader_location_len_over_64k()
void srn_sched_run(srn_scheduler_t *sched, size_t nworkers)
Run the scheduler with nworkers os threads draining it, returning once the pool goes quiescent (every...
size_t len
logical length.
srn_engine_t * engine
Long term state of the compiler.
srn_scheduler_t * scheduler
The fiber scheduler, that is the entry point of the fiber subsystem.
A runtime error, a tag classifying the failure and a human-readable message.
union srn_error_t::@110141362101221075206211275212023153042233307220 as
union srn_sexp_node_t::@313353022266020117306231170157030062126255275140 as
srn_sexp_node_type_e type
srn_metadata_t * metadata
uint32_t len
Length of the form in bytes.
uint32_t offset
Byte offset of the form's first byte in the buffer.