Restructure into umbrella modules (~55 -> 16 targets)

Headers move, CMake targets merge, C++ namespaces stay unchanged:
- Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant
- Functional: Pipeline, Either, Result, Retry
- Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval
- Math: +Matrix, Numeric, Random, Histogram
- Text: Str, Format, Tokenizer, Diff, Encoding, Semver
- Data: Json, Csv, Ini
- Async: Coro, Concurrency, EventBus, Observable
- Time: +Bench
- Log: Log facade + Logging framework (facade now header-only, breaking
  the Stacktrace<->Log link cycle the merge would have created)
- System: FileSystem + Process
- Configuration: +Argparse
- Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail

Module system fixes:
- OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no
  longer depends on the alphabetical discovery order of src/ subdirs
  (Testing -> Text would have been silently dropped).
- Every header-only module now has a tracked module.cmake; previously the
  empty src/<Name> marker dirs were untracked, so a fresh clone would have
  silently skipped those modules.
- VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT.

Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files
prefixed: ResultBasic etc.). Test count verified identical (831) before and
after. README/CLAUDE.md module tables updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Fable 5 committed 2026-06-12 18:50:02 +03:00
1 parent da2e93c405
commit 28b94883fd
156 files changed
+278 -220

No files matched your search

+217
View File
@@ -0,0 +1,217 @@
#include <Void/Math/Matrix.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
using namespace Void::Matrix;
// ── construction ──────────────────────────────────────────────────────────────
Void::Testing::Test matrix_default_zeros()
{
const Mat2<int> m;
Void::Testing::expect_eq(m(0, 0), 0);
Void::Testing::expect_eq(m(1, 1), 0);
}
Void::Testing::Test matrix_fill_constructor()
{
const Matrix<int, 3, 3> m{5};
Void::Testing::expect_eq(m(0, 0), 5);
Void::Testing::expect_eq(m(2, 2), 5);
}
Void::Testing::Test matrix_array_init()
{
const Mat2<int> m{{1, 2, 3, 4}};
Void::Testing::expect_eq(m(0, 0), 1);
Void::Testing::expect_eq(m(0, 1), 2);
Void::Testing::expect_eq(m(1, 0), 3);
Void::Testing::expect_eq(m(1, 1), 4);
}
Void::Testing::Test matrix_identity_factory()
{
const auto id = Mat3<int>::identity();
Void::Testing::expect_eq(id(0, 0), 1);
Void::Testing::expect_eq(id(1, 1), 1);
Void::Testing::expect_eq(id(2, 2), 1);
Void::Testing::expect_eq(id(0, 1), 0);
Void::Testing::expect_eq(id(1, 0), 0);
}
Void::Testing::Test matrix_at_out_of_range()
{
const Mat2<int> m;
bool threw = false;
try { [[maybe_unused]] auto v = m.at(5, 0); } catch (...) { threw = true; }
Void::Testing::expect(threw);
}
// ── arithmetic ────────────────────────────────────────────────────────────────
Void::Testing::Test matrix_add()
{
const Mat2<int> a{{1, 2, 3, 4}};
const Mat2<int> b{{5, 6, 7, 8}};
const auto c = a + b;
Void::Testing::expect_eq(c(0, 0), 6);
Void::Testing::expect_eq(c(1, 1), 12);
}
Void::Testing::Test matrix_subtract()
{
const Mat2<int> a{{10, 8, 6, 4}};
const Mat2<int> b{{1, 2, 3, 4}};
const auto c = a - b;
Void::Testing::expect_eq(c(0, 0), 9);
Void::Testing::expect_eq(c(1, 0), 3);
}
Void::Testing::Test matrix_scalar_mul()
{
const Mat2<int> m{{1, 2, 3, 4}};
const auto r = m * 3;
Void::Testing::expect_eq(r(0, 0), 3);
Void::Testing::expect_eq(r(1, 1), 12);
}
Void::Testing::Test matrix_scalar_mul_left()
{
const Mat2<int> m{{1, 2, 3, 4}};
const auto r = 2 * m;
Void::Testing::expect_eq(r(0, 1), 4);
}
Void::Testing::Test matrix_negate()
{
const Mat2<int> m{{1, -2, 3, -4}};
const auto n = -m;
Void::Testing::expect_eq(n(0, 0), -1);
Void::Testing::expect_eq(n(0, 1), 2);
}
Void::Testing::Test matrix_mul_identity()
{
const Mat2<int> m{{1, 2, 3, 4}};
const auto id = Mat2<int>::identity();
const auto result = m * id;
Void::Testing::expect_eq(result, m);
}
Void::Testing::Test matrix_mul_2x2()
{
// [1 2] * [5 6] = [1*5+2*7 1*6+2*8] = [19 22]
// [3 4] [7 8] [3*5+4*7 3*6+4*8] [43 50]
const Mat2<int> a{{1, 2, 3, 4}};
const Mat2<int> b{{5, 6, 7, 8}};
const auto c = a * b;
Void::Testing::expect_eq(c(0, 0), 19);
Void::Testing::expect_eq(c(0, 1), 22);
Void::Testing::expect_eq(c(1, 0), 43);
Void::Testing::expect_eq(c(1, 1), 50);
}
Void::Testing::Test matrix_mul_non_square()
{
// [1 2 3] (1×3) * [1] (3×1) = [1+4+9] = [14] (1×1)
// [2]
// [3]
Matrix<int, 1, 3> row{{1, 2, 3}};
Matrix<int, 3, 1> col{{1, 2, 3}};
const auto r = row * col;
Void::Testing::expect_eq(r(0, 0), 14);
}
// ── transpose ─────────────────────────────────────────────────────────────────
Void::Testing::Test matrix_transpose()
{
const Mat2<int> m{{1, 2, 3, 4}};
const auto t = m.transposed();
Void::Testing::expect_eq(t(0, 0), 1);
Void::Testing::expect_eq(t(0, 1), 3);
Void::Testing::expect_eq(t(1, 0), 2);
Void::Testing::expect_eq(t(1, 1), 4);
}
Void::Testing::Test matrix_transpose_non_square()
{
Matrix<int, 2, 3> m{{1, 2, 3, 4, 5, 6}};
const auto t = m.transposed();
static_assert(decltype(t)::rows == 3 && decltype(t)::cols == 2);
Void::Testing::expect_eq(t(0, 0), 1);
Void::Testing::expect_eq(t(2, 0), 3);
Void::Testing::expect_eq(t(0, 1), 4);
}
// ── aggregates ────────────────────────────────────────────────────────────────
Void::Testing::Test matrix_sum()
{
const Mat2<int> m{{1, 2, 3, 4}};
Void::Testing::expect_eq(m.sum(), 10);
}
Void::Testing::Test matrix_trace()
{
const Mat3<int> m{{1, 0, 0,
0, 2, 0,
0, 0, 3}};
Void::Testing::expect_eq(m.trace(), 6);
}
// ── determinant ───────────────────────────────────────────────────────────────
Void::Testing::Test matrix_det_2x2()
{
const Mat2<int> m{{1, 2, 3, 4}};
Void::Testing::expect_eq(det(m), -2); // 1*4 - 2*3
}
Void::Testing::Test matrix_det_3x3()
{
const Mat3<int> m{{1, 2, 3,
4, 5, 6,
7, 8, 9}};
Void::Testing::expect_eq(det(m), 0); // singular
}
// ── inverse ───────────────────────────────────────────────────────────────────
Void::Testing::Test matrix_inverse_2x2()
{
const Mat2<double> m{{1.0, 2.0, 3.0, 4.0}};
const auto inv = inverse(m);
Void::Testing::expect(inv.has_value());
// m * inv should equal identity
const auto prod = m * *inv;
Void::Testing::expect(prod(0, 0) > 0.999 && prod(0, 0) < 1.001);
Void::Testing::expect(prod(1, 1) > 0.999 && prod(1, 1) < 1.001);
Void::Testing::expect(prod(0, 1) > -0.001 && prod(0, 1) < 0.001);
}
Void::Testing::Test matrix_inverse_singular_returns_nullopt()
{
const Mat2<double> m{{1.0, 2.0, 2.0, 4.0}}; // det = 0
Void::Testing::expect(!inverse(m).has_value());
}
// ── dot product ───────────────────────────────────────────────────────────────
Void::Testing::Test matrix_dot_product()
{
Vec3<int> a{{1, 2, 3}};
Vec3<int> b{{4, 5, 6}};
Void::Testing::expect_eq(dot(a, b), 32); // 4+10+18
}
// ── equality ──────────────────────────────────────────────────────────────────
Void::Testing::Test matrix_equality()
{
const Mat2<int> a{{1, 2, 3, 4}};
const Mat2<int> b{{1, 2, 3, 4}};
const Mat2<int> c{{1, 2, 3, 5}};
Void::Testing::expect(a == b);
Void::Testing::expect(a != c);
}