Implemented test_array_struct_inline_value test helper function
This commit is contained in:
parent
c7bd3bea12
commit
1cf292d3e5
|
|
@ -131,8 +131,8 @@ typedef struct {
|
||||||
} TypeTuple;
|
} TypeTuple;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
TokenString values;
|
void **values;
|
||||||
Identifier name;
|
const char *name;
|
||||||
} StructInline;
|
} StructInline;
|
||||||
|
|
||||||
typedef struct ArrayLiteral {
|
typedef struct ArrayLiteral {
|
||||||
|
|
@ -146,7 +146,7 @@ typedef struct ArrayLiteral {
|
||||||
Boolean *boolean_literals; // type == ARRAY_BOOLEAN
|
Boolean *boolean_literals; // type == ARRAY_BOOLEAN
|
||||||
TokenString *token_strings; // type == ARRAY_TOKEN_STRING
|
TokenString *token_strings; // type == ARRAY_TOKEN_STRING
|
||||||
TypeTuple *type_tuples; // type == ARRAY_TYPE_TUPLE
|
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 *shape;
|
||||||
size_t dimensions;
|
size_t dimensions;
|
||||||
|
|
|
||||||
|
|
@ -492,13 +492,31 @@ static Boolean test_array_boolean_value(LexerTest *test, LexerResult result, siz
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Boolean test_array_struct_inline_value(LexerTest *test, LexerResult result, size_t i, void *values, size_t *shape, size_t dimensions) {
|
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) {
|
||||||
error_test(test, result, (SlsError) { .message = "Test case not implemented!", .code = 984, });
|
static const ArrayType array_type = ARRAY_STRUCT_INLINE;
|
||||||
// TODO
|
LexerTokenResult *head = get_token(result.result, i);
|
||||||
|
if (test_array_type(test, result, i, array_type, shape, dimensions)) {
|
||||||
return TRUE;
|
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 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, });
|
error_test(test, result, (SlsError) { .message = "Test case not implemented!", .code = 984, });
|
||||||
// TODO
|
// TODO
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue