Implemented test_array_struct_inline_value test helper function

This commit is contained in:
Kyler Olsen 2025-11-01 00:04:37 -06:00
parent c7bd3bea12
commit 1cf292d3e5
2 changed files with 25 additions and 7 deletions

View File

@ -131,8 +131,8 @@ typedef struct {
} TypeTuple;
typedef struct {
TokenString values;
Identifier name;
void **values;
const char *name;
} StructInline;
typedef struct ArrayLiteral {
@ -146,7 +146,7 @@ typedef struct ArrayLiteral {
Boolean *boolean_literals; // type == ARRAY_BOOLEAN
TokenString *token_strings; // type == ARRAY_TOKEN_STRING
TypeTuple *type_tuples; // type == ARRAY_TYPE_TUPLE
StructInline *type_tuples; // type == ARRAY_STRUCT_INLINE
StructInline struct_inline; // type == ARRAY_STRUCT_INLINE
};
size_t *shape;
size_t dimensions;

View File

@ -492,13 +492,31 @@ static Boolean test_array_boolean_value(LexerTest *test, LexerResult result, siz
return FALSE;
}
static Boolean test_array_struct_inline_value(LexerTest *test, LexerResult result, size_t i, void *values, size_t *shape, size_t dimensions) {
error_test(test, result, (SlsError) { .message = "Test case not implemented!", .code = 984, });
// TODO
static Boolean test_array_struct_inline_value(LexerTest *test, LexerResult result, size_t i, size_t struct_name_length, const char *struct_name, Boolean (*struct_handler)(LexerTest *, LexerResult, size_t, size_t, void *, void *), void **values, size_t *shape, size_t dimensions) {
static const ArrayType array_type = ARRAY_STRUCT_INLINE;
LexerTokenResult *head = get_token(result.result, i);
if (test_array_type(test, result, i, array_type, shape, dimensions)) {
return TRUE;
} if (strncmp(head->result.array_literal.struct_inline.name, struct_name, struct_name_length)) {
logic_fail_test(test, result, token_value_string_should_be(i + 1, ARRAY_STRUCT_INLINE, struct_name_length, struct_name, head->result.array_literal.struct_inline.name));
return TRUE;
}
size_t length = 1;
for (int j = 0; j < dimensions; j++) length *= shape[j];
for (int j = 0; j < length; j++) {
if (struct_handler(test, result, i, j, head->result.array_literal.struct_inline.values[j], values[j])) {
return TRUE;
}
}
return FALSE;
}
static Boolean test_token_string_value(LexerTest *test, LexerResult result, size_t i, void *value) {
static const TokenType token_type = TOKEN_TOKEN_STRING;
LexerTokenResult *head = get_token(result.result, i);
if (test_token_type(test, result, i, token_type)) {
return TRUE;
}
error_test(test, result, (SlsError) { .message = "Test case not implemented!", .code = 984, });
// TODO
return TRUE;