Skip to content

test: add 56 unit tests for semantic, slab_alloc, and ast_profile modules#681

Merged
DeusData merged 3 commits into
DeusData:mainfrom
RollerCoaster1899:test/add-unit-tests-semantic-slab-astprofile
Jul 4, 2026
Merged

test: add 56 unit tests for semantic, slab_alloc, and ast_profile modules#681
DeusData merged 3 commits into
DeusData:mainfrom
RollerCoaster1899:test/add-unit-tests-semantic-slab-astprofile

Conversation

@RollerCoaster1899

Copy link
Copy Markdown
Contributor

Summary

Adds 56 unit tests across 3 new test files for previously untested modules:

  • tests/test_semantic.c (32 tests): cbm_sem_tokenize (camel/snake/dot/abbrev), cbm_sem_cosine (identical/orthogonal/zero/negative/null), cbm_sem_normalize, cbm_sem_vec_add_scaled, cbm_sem_random_index (determinism), cbm_sem_proximity, cbm_sem_diffuse, corpus lifecycle, IDF, config
  • tests/test_slab_alloc.c (14 tests): Slab malloc/free (≤64B and >64B), calloc zeroing/overflow, realloc (shrink/promote/same-size), free-list cycling, pointer uniqueness, thread reset
  • tests/test_ast_profile.c (10 tests): to_str/from_str round-trip (25 fields), null/empty/invalid inputs, to_vector range/saturation

Verification

./build/c/test-runner semantic ast_profile slab_alloc

All 56 pass with ASan+UBSan.

Files modified

  • Makefile.cbm: Register new test sources in ALL_TEST_SRCS
  • tests/test_main.c: Register suite_semantic, suite_ast_profile, suite_slab_alloc

…ules

Add focused unit tests for three previously untested modules:

- tests/test_semantic.c (32 tests): cbm_sem_tokenize (camel/snake/dot/abbrev),
  cbm_sem_cosine (identical/orthogonal/zero/negative/null),
  cbm_sem_normalize, cbm_sem_vec_add_scaled,
  cbm_sem_random_index (determinism), cbm_sem_proximity,
  cbm_sem_diffuse, corpus lifecycle, IDF, config

- tests/test_slab_alloc.c (14 tests): slab malloc/free (≤64B and >64B),
  calloc zeroing/overflow, realloc (shrink/promote/same-size),
  free-list cycling, pointer uniqueness, thread reset

- tests/test_ast_profile.c (10 tests): to_str/from_str round-trip
  (25 fields), null/empty/invalid inputs, to_vector range/saturation

All 56 tests pass with ASan+UBSan. Registered in Makefile.cbm
and test_main.c.

Signed-off-by: Raul Acosta <raulacosta@users.noreply.github.com>
Signed-off-by: Raul Acosta <raul.acosta.mmm@gmail.com>
@RollerCoaster1899 RollerCoaster1899 force-pushed the test/add-unit-tests-semantic-slab-astprofile branch from 9c50b26 to 08437cf Compare June 29, 2026 15:45
@DeusData

Copy link
Copy Markdown
Owner

Huge thanks for opening this PR and for the work you put into it.

The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime.

@DeusData DeusData added priority/backlog Valuable contribution, lower scheduling urgency; review when maintainer capacity opens. enhancement New feature or request labels Jun 29, 2026
@DeusData

DeusData commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Thanks for adding coverage. Before review can continue, please add a DCO Signed-off-by trailer to the non-merge commit and link the issue or coverage goal this addresses. Since these tests are added to ALL_TEST_SRCS, please also include the full test command/output.

@DeusData DeusData added parsing/quality Graph extraction bugs, false positives, missing edges stability/performance Server crashes, OOM, hangs, high CPU/memory labels Jul 4, 2026
@DeusData DeusData merged commit a4e1f21 into DeusData:main Jul 4, 2026
14 checks passed
@DeusData

DeusData commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Thank you — these are genuine, non-vacuous guards (exact-value assertions on the semantic proximity/cosine math, slab calloc-overflow + realloc-promotion, and the 25-field ast_profile roundtrip), not coverage padding, and they're black-box on the public slab API. That last part is timely: there's an in-flight slab-allocator redesign (cross-thread frees / #852), and this suite is exactly the independent regression net it needs. Merged as a4e1f21. Appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request parsing/quality Graph extraction bugs, false positives, missing edges priority/backlog Valuable contribution, lower scheduling urgency; review when maintainer capacity opens. stability/performance Server crashes, OOM, hangs, high CPU/memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants