Update.
All checks were successful
CI / Optimization Infrastructure Tests (push) Successful in 22s
CI / Unit Tests (push) Successful in 23s
CI / Integration Tests (push) Successful in 31s
CI / Performance Benchmark (push) Successful in 56s

This commit is contained in:
retoor 2025-12-05 01:23:43 +01:00
parent b46f0d9ff4
commit fca0ade573
2 changed files with 99 additions and 1 deletions

View File

@ -155,7 +155,7 @@ UNITTEST_OBJECTS = $(UNITTEST_SOURCES:.c=.o)
TEST_UNITTEST_DEMO_SOURCES = tests/test_unittest_demo.c
TEST_UNITTEST_DEMO_OBJECTS = $(TEST_UNITTEST_DEMO_SOURCES:.c=.o)
all: test_lexer test_parser test_semantic test_ir test_runtime test_strings test_arrays test_objects test_instance_methods test_fileio test_dowhile test_switch test_math test_string_methods test_static test_interfaces test_exceptions test_ternary test_bitwise test_enhanced_for test_array_init test_instanceof test_shortcircuit test_multidim_arrays test_static_init test_negative test_enums test_collections test_super test_inheritance test_break test_elseif test_forloop test_println test_loader test_object_methods test_autobox
all: test_lexer test_parser test_semantic test_ir test_runtime test_strings test_arrays test_objects test_instance_methods test_fileio test_dowhile test_switch test_math test_string_methods test_static test_interfaces test_exceptions test_ternary test_bitwise test_enhanced_for test_array_init test_instanceof test_shortcircuit test_multidim_arrays test_static_init test_negative test_enums test_collections test_super test_inheritance test_break test_elseif test_forloop test_println test_loader test_object_methods test_autobox test_gc
test_lexer: $(LEXER_OBJECTS) $(UNITTEST_OBJECTS) $(TEST_LEXER_OBJECTS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

View File

@ -105,6 +105,100 @@ UnittestTestResult_t* test_gc_hashmap(void) {
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_gc_collection_triggered(void) {
UNITTEST_BEGIN_TEST("TestGC", "test_gc_collection_triggered");
const char *source =
"public class Test {\n"
" public static int main() {\n"
" int count = 0;\n"
" for (int i = 0; i < 10000; i++) {\n"
" int[] temp = new int[100];\n"
" temp[0] = i;\n"
" count = count + 1;\n"
" }\n"
" return count;\n"
" }\n"
"}\n";
RAVA_TEST_RUN(_unittest_result, source, "Test", "main", 10000,
"Should handle many temporary allocations via GC");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_gc_circular_references(void) {
UNITTEST_BEGIN_TEST("TestGC", "test_gc_circular_references");
const char *source =
"public class Test {\n"
" public static int main() {\n"
" int sum = 0;\n"
" for (int i = 0; i < 100; i++) {\n"
" int[] a = new int[10];\n"
" int[] b = new int[10];\n"
" a[0] = i;\n"
" b[0] = i * 2;\n"
" sum = sum + a[0] + b[0];\n"
" }\n"
" return sum;\n"
" }\n"
"}\n";
RAVA_TEST_RUN(_unittest_result, source, "Test", "main", 14850,
"Should handle many paired allocations");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_gc_deep_object_graph(void) {
UNITTEST_BEGIN_TEST("TestGC", "test_gc_deep_object_graph");
const char *source =
"public class Test {\n"
" public static int main() {\n"
" int[][] matrix = new int[50][50];\n"
" int sum = 0;\n"
" for (int i = 0; i < 50; i++) {\n"
" for (int j = 0; j < 50; j++) {\n"
" matrix[i][j] = i + j;\n"
" sum = sum + matrix[i][j];\n"
" }\n"
" }\n"
" return sum;\n"
" }\n"
"}\n";
RAVA_TEST_RUN(_unittest_result, source, "Test", "main", 122500,
"Should handle nested array allocations");
UNITTEST_END_TEST();
}
UnittestTestResult_t* test_gc_mixed_types(void) {
UNITTEST_BEGIN_TEST("TestGC", "test_gc_mixed_types");
const char *source =
"public class Test {\n"
" public static int main() {\n"
" int[] data = new int[50];\n"
" for (int i = 0; i < 50; i++) {\n"
" data[i] = i * 2;\n"
" }\n"
" int sum = 0;\n"
" for (int j = 0; j < 50; j++) {\n"
" sum = sum + data[j];\n"
" }\n"
" return sum;\n"
" }\n"
"}\n";
RAVA_TEST_RUN(_unittest_result, source, "Test", "main", 2450,
"Should handle array operations");
UNITTEST_END_TEST();
}
int main(int argc, char **argv) {
UnittestConfig_t *config = unittest_config_create();
config->verbosity = 2;
@ -122,6 +216,10 @@ int main(int argc, char **argv) {
unittest_test_case_add_result(tc, test_gc_many_allocations());
unittest_test_case_add_result(tc, test_gc_arraylist());
unittest_test_case_add_result(tc, test_gc_hashmap());
unittest_test_case_add_result(tc, test_gc_collection_triggered());
unittest_test_case_add_result(tc, test_gc_circular_references());
unittest_test_case_add_result(tc, test_gc_deep_object_graph());
unittest_test_case_add_result(tc, test_gc_mixed_types());
unittest_test_suite_add_test_case(suite, tc);
unittest_generate_report(suite, config);