Repository navigation
refactor(tests): extract fixed_point_misc.cpp (part of #3130, meta #3127) - #3135
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe CI test-file-pairing hook is extended with a sibling-split allowance that accepts a new test file when its base name is a suffix-stripped variant of an already-paired test/header pair. Under that rule, 414 lines of miscellaneous fixed-point tests are moved verbatim from ChangesFixed-point test split with enabling CI hook change
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ci/hooks/check_test_file_pairing.py (1)
25-25: ⚡ Quick winAdd return type annotation to
main()function.The function is missing an explicit return type annotation. As per coding guidelines, all function return types MUST have explicit type annotations.
✨ Proposed fix
-def main(): +def main() -> None:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/hooks/check_test_file_pairing.py` at line 25, The main() function definition is missing an explicit return type annotation, which violates coding guidelines requiring all functions to have explicit return types. Add the appropriate return type annotation to the main() function signature following the closing parenthesis. Determine the correct return type based on what the function returns (typically -> None if it performs operations without returning a value).Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ci/hooks/check_test_file_pairing.py`:
- Line 25: The main() function definition is missing an explicit return type
annotation, which violates coding guidelines requiring all functions to have
explicit return types. Add the appropriate return type annotation to the main()
function signature following the closing parenthesis. Determine the correct
return type based on what the function returns (typically -> None if it performs
operations without returning a value).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2588d0f3-110d-45d0-9fca-eb7377050c4a
📒 Files selected for processing (3)
ci/hooks/check_test_file_pairing.pytests/fl/math/fixed_point.cpptests/fl/math/fixed_point_misc.cpp
💤 Files with no reviewable changes (1)
- tests/fl/math/fixed_point.cpp
…art of #3130, meta #3127) First extraction in the fixed_point.cpp split (#3130). Moves the misc section (lines 4818-5226) into its own file: - Fixed-point scalar type alignment tests - Constexpr scalar multiply/divide tests (s0x32, u0x32) - Integer constructor tests (PR #2197 int width portability) - pow boundary regression tests (#2969) Also extends ci/hooks/check_test_file_pairing.py to allow sibling-split test files. The original 1:1 pairing rule rejected fixed_point_misc.cpp because there is no src/fl/math/fixed_point_misc.h. The new sibling-split allowance walks back the base name via underscore separators and allows the write when the longest base prefix has both an existing paired test file and a matching src header. This unblocks the rest of #3127's splits without weakening the convention for genuinely unpaired test files. Tests pass: bash test fl_math_fixed_point --cpp (1/1, 17/17 build steps). fixed_point.cpp: 5,230 -> 4,816 LOC fixed_point_misc.cpp (new): 440 LOC Part of #3130. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
29dcda2 to
786dcaa
Compare
…pp (part of #3130) Second extraction in #3130. Moves the constexpr validation section (original lines 811-1129 + the constexpr_raw_check helper at 120-124) into its own file: - constexpr raw() compile-time check (all 13 types) - constexpr from_raw compile-time check - constexpr arithmetic operators - constexpr comparisons - constexpr conversions - constexpr math functions (mod, floor, ceil, fract, abs, sign, lerp, clamp, step, sqrt, rsqrt) - constexpr value verification (concrete value computations) Plus the 23 constexpr_*_check<T>(...) helper templates that the tests use; they were only referenced by the moved test cases. The original section header "Concrete Bit-Exact Tests (All Types)" now correctly introduces the bit-exact tests that remain in fixed_point.cpp. Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.27s test time). fixed_point.cpp: 4,816 -> 4,488 LOC fixed_point_constexpr.cpp (new): 343 LOC Stacked on top of feat/3130-fixed-point-misc-extract (PR #3135) because both PRs depend on the same ci/hooks/check_test_file_pairing.py sibling- split allowance that #3135 introduces. Part of #3130. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…pp (part of #3130) (#3159) Second extraction in #3130. Moves the constexpr validation section (original lines 811-1129 + the constexpr_raw_check helper at 120-124) into its own file: - constexpr raw() compile-time check (all 13 types) - constexpr from_raw compile-time check - constexpr arithmetic operators - constexpr comparisons - constexpr conversions - constexpr math functions (mod, floor, ceil, fract, abs, sign, lerp, clamp, step, sqrt, rsqrt) - constexpr value verification (concrete value computations) Plus the 23 constexpr_*_check<T>(...) helper templates that the tests use; they were only referenced by the moved test cases. The original section header "Concrete Bit-Exact Tests (All Types)" now correctly introduces the bit-exact tests that remain in fixed_point.cpp. Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.27s test time). fixed_point.cpp: 4,816 -> 4,488 LOC fixed_point_constexpr.cpp (new): 343 LOC Stacked on top of feat/3130-fixed-point-misc-extract (PR #3135) because both PRs depend on the same ci/hooks/check_test_file_pairing.py sibling- split allowance that #3135 introduces. Part of #3130. Meta tracking issue: #3127. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…3130) Third extraction in #3130, the keystone for the remaining four per-type PRs. Moves the accuracy_bounds<T> template specialization table (original lines 126-331 = 6 specializations + their out-of-line definitions) into a new shared header. Include pattern: each consumer .cpp file includes fixed_point_bounds.h from WITHIN its anonymous namespace, so each translation unit gets its own private copy. This avoids ODR concerns with the out-of-line constexpr static member definitions, which are still required for C++11/C++14 compatibility on this codebase. Header uses fully-qualified fl::s4x12 etc., so it works regardless of whether the consumer has 'using namespace fl;' in scope. Unblocks the upcoming per-type extractions: - fixed_point_signed_types.cpp - fixed_point_u4x12_u8x8.cpp - fixed_point_u12x4_u16x16.cpp - fixed_point_u8x24_u24x8.cpp Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.28s test time, 69.5s build). fixed_point.cpp: 4,488 -> 4,277 LOC fixed_point_bounds.h (new): 230 LOC Stacked on feat/3130-fixed-point-constexpr-extract (PR #3136), which is stacked on feat/3130-fixed-point-misc-extract (PR #3135). Both predecessors are required because they introduce the ci/hooks/check_test_file_pairing.py sibling-split allowance. Part of #3130. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…3130) (#3160) Third extraction in #3130, the keystone for the remaining four per-type PRs. Moves the accuracy_bounds<T> template specialization table (original lines 126-331 = 6 specializations + their out-of-line definitions) into a new shared header. Include pattern: each consumer .cpp file includes fixed_point_bounds.h from WITHIN its anonymous namespace, so each translation unit gets its own private copy. This avoids ODR concerns with the out-of-line constexpr static member definitions, which are still required for C++11/C++14 compatibility on this codebase. Header uses fully-qualified fl::s4x12 etc., so it works regardless of whether the consumer has 'using namespace fl;' in scope. Unblocks the upcoming per-type extractions: - fixed_point_signed_types.cpp - fixed_point_u4x12_u8x8.cpp - fixed_point_u12x4_u16x16.cpp - fixed_point_u8x24_u24x8.cpp Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.28s test time, 69.5s build). fixed_point.cpp: 4,488 -> 4,277 LOC fixed_point_bounds.h (new): 230 LOC Stacked on feat/3130-fixed-point-constexpr-extract (PR #3136), which is stacked on feat/3130-fixed-point-misc-extract (PR #3135). Both predecessors are required because they introduce the ci/hooks/check_test_file_pairing.py sibling-split allowance. Part of #3130. Meta tracking issue: #3127. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…cpp (part of #3130) Fourth extraction in #3130. Moves the u4x12 + u8x8 unsigned type tests into their own file. Both share a section because they share the file-local approx_equal() helper (used only within these two sections). Content moved: - 28 FL_TEST_CASE u4x12 tests (construction, arithmetic, math ops, edge cases, precision, compound operations) - 60+ FL_TEST_CASE u8x8 tests (construction variants, addition/sub/ mul/div, shifts, comparisons, math ops, sqrt/rsqrt/pow, edge cases) - approx_equal() static helper (lines 1644-1646 of original) Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.23s test time, 44s build). fixed_point.cpp: 4,277 -> 3,404 LOC fixed_point_u4x12_u8x8.cpp (new): 896 LOC Stacked on feat/3130-fixed-point-bounds-header (PR #3138). Predecessors: - feat/3130-fixed-point-misc-extract (PR #3135 — hook + misc) - feat/3130-fixed-point-constexpr-extract (PR #3136 — constexpr) - feat/3130-fixed-point-bounds-header (PR #3138 — bounds.h) Part of #3130. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…cpp (part of #3130) (#3161) Fourth extraction in #3130. Moves the u4x12 + u8x8 unsigned type tests into their own file. Both share a section because they share the file-local approx_equal() helper (used only within these two sections). Content moved: - 28 FL_TEST_CASE u4x12 tests (construction, arithmetic, math ops, edge cases, precision, compound operations) - 60+ FL_TEST_CASE u8x8 tests (construction variants, addition/sub/ mul/div, shifts, comparisons, math ops, sqrt/rsqrt/pow, edge cases) - approx_equal() static helper (lines 1644-1646 of original) Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.23s test time, 44s build). fixed_point.cpp: 4,277 -> 3,404 LOC fixed_point_u4x12_u8x8.cpp (new): 896 LOC Stacked on feat/3130-fixed-point-bounds-header (PR #3138). Predecessors: - feat/3130-fixed-point-misc-extract (PR #3135 — hook + misc) - feat/3130-fixed-point-constexpr-extract (PR #3136 — constexpr) - feat/3130-fixed-point-bounds-header (PR #3138 — bounds.h) Part of #3130. Meta tracking issue: #3127. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…rt of #3130) — closes the loop Seventh extraction in #3130. Moves all the test infrastructure templates into a shared header. With this PR, fixed_point.cpp drops to 613 LOC — under the meta 1K-LOC target. Together with PRs #3135, #3136, #3138, #3139, #3142, #3143, the original 5,230-LOC monolith is fully decomposed. Content moved (1053 LOC of helpers from 5 non-contiguous ranges): - test_*_impl<T> bit-exact helpers (original lines 131-585) - AccuracyResult struct + non-templated measure_* helpers + print_row helpers (original lines 838-1054) - measure_*_t<T> templated helpers + run_type_accuracy<T> (original lines 1120-1356) - test_bit_exact_equivalence<Tmpl, Conc> (original lines 1369-1430) - check_all_accuracy_bounds<T> regression gate (original lines 1456-1515) Same include pattern as fixed_point_bounds.h: each consumer .cpp file includes from WITHIN its anonymous namespace, after bounds.h. Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.37s test time, 117s build). fixed_point.cpp: 1,643 -> 613 LOC (under 1K target) fixed_point_test_helpers.h (new): 1053 LOC (header, no LOC cap) After this PR, fixed_point.cpp contains only: - includes + FL_TEST_FILE wrapper + namespace + raw_t + check_near + FP_TYPES macro + includes to bounds.h and test_helpers.h - Bit-exact test cases (CHECK_EQ-based) - Transcendental test cases (CHECK_CLOSE with bounds) - s16x16 accuracy report - multi-type accuracy report - fixed_point<N,M> vs sNxM bit-exact tests - per-type accuracy bounds tests - GitHub #2174 regression test - to_float comprehensive test Stacked on feat/3130-fixed-point-u8x24-u24x8-extract (PR #3143). Closes #3130 once all 7 stacked PRs merge. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rt of #3130) — closes the loop (#3164) Seventh extraction in #3130. Moves all the test infrastructure templates into a shared header. With this PR, fixed_point.cpp drops to 613 LOC — under the meta 1K-LOC target. Together with PRs #3135, #3136, #3138, #3139, #3142, #3143, the original 5,230-LOC monolith is fully decomposed. Content moved (1053 LOC of helpers from 5 non-contiguous ranges): - test_*_impl<T> bit-exact helpers (original lines 131-585) - AccuracyResult struct + non-templated measure_* helpers + print_row helpers (original lines 838-1054) - measure_*_t<T> templated helpers + run_type_accuracy<T> (original lines 1120-1356) - test_bit_exact_equivalence<Tmpl, Conc> (original lines 1369-1430) - check_all_accuracy_bounds<T> regression gate (original lines 1456-1515) Same include pattern as fixed_point_bounds.h: each consumer .cpp file includes from WITHIN its anonymous namespace, after bounds.h. Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.37s test time, 117s build). fixed_point.cpp: 1,643 -> 613 LOC (under 1K target) fixed_point_test_helpers.h (new): 1053 LOC (header, no LOC cap) After this PR, fixed_point.cpp contains only: - includes + FL_TEST_FILE wrapper + namespace + raw_t + check_near + FP_TYPES macro + includes to bounds.h and test_helpers.h - Bit-exact test cases (CHECK_EQ-based) - Transcendental test cases (CHECK_CLOSE with bounds) - s16x16 accuracy report - multi-type accuracy report - fixed_point<N,M> vs sNxM bit-exact tests - per-type accuracy bounds tests - GitHub #2174 regression test - to_float comprehensive test Stacked on feat/3130-fixed-point-u8x24-u24x8-extract (PR #3143). Closes #3130 once all 7 stacked PRs merge. Meta tracking issue: #3127. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
… of #3131) First extraction in #3131 (string.cpp split, sub-issue of #3127). Moves the smallest section (lines 3898-4271 of original, 'Tests from string_memory_bugs.cpp') into its own file. Content moved (375 LOC): - StringHolder - Capacity off-by-one bugs - StringHolder - hasCapacity checks - StringHolder - Edge cases exposing capacity bugs - StringHolder - Memory safety with incorrect capacity Tests pass: bash test fl_stl_string --cpp (1/1, 0.26s test time, 80s build). string.cpp: 6,468 -> 6,093 LOC string_memory_bugs.cpp (new): 389 LOC Stacked on feat/3130-fixed-point-test-helpers-header (PR #3144) for the sibling-split hook update introduced in #3135. Part of #3131. Meta tracking issue: #3127. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… of #3131) (#3165) First extraction in #3131 (string.cpp split, sub-issue of #3127). Moves the smallest section (lines 3898-4271 of original, 'Tests from string_memory_bugs.cpp') into its own file. Content moved (375 LOC): - StringHolder - Capacity off-by-one bugs - StringHolder - hasCapacity checks - StringHolder - Edge cases exposing capacity bugs - StringHolder - Memory safety with incorrect capacity Tests pass: bash test fl_stl_string --cpp (1/1, 0.26s test time, 80s build). string.cpp: 6,468 -> 6,093 LOC string_memory_bugs.cpp (new): 389 LOC Stacked on feat/3130-fixed-point-test-helpers-header (PR #3144) for the sibling-split hook update introduced in #3135. Part of #3131. Meta tracking issue: #3127. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
First extraction in the
tests/fl/math/fixed_point.cppsplit tracked by #3130 (sub-issue of meta #3127). Moves the file's last section (lines 4818-5226, ~410 LOC) into its own file.Sections moved into
fixed_point_misc.cpp:powboundary regression tests (fl::fixed_point::pow boundary handling: x=0 and x≈1 produce wrong results #2969)LOC delta:
tests/fl/math/fixed_point.cpp: 5,230 → 4,816 LOC (still over 1K — 7 more extractions to go per Split tests/fl/math/fixed_point.cpp (5,230 LOC) into 8 files of <1K LOC each (sub-issue of #3127) #3130)tests/fl/math/fixed_point_misc.cpp(new): 440 LOCHook change
ci/hooks/check_test_file_pairing.pyis extended with a sibling-split allowance. The original 1:1 pairing rule rejectedfixed_point_misc.cppbecause there is nosrc/fl/math/fixed_point_misc.h(and there shouldn't be —fixed_point.his the only public header). The new logic walks back the base name via underscore separators and allows the write when the longest base prefix has both an existing paired test file and a matchingsrc/header:tests/fl/math/fixed_point_misc.cpp→ walks back tofixed_point→ findstests/fl/math/fixed_point.cpp+src/fl/math/fixed_point.h→ allow.tests/fl/stl/string_basic_a.cpp→string_basic(no match) →string→ findstests/fl/stl/string.cpp+src/fl/stl/string.h→ allow.This unblocks the rest of #3127's planned 24-PR split sequence without weakening the convention for genuinely unpaired tests (those still go to
tests/misc/).Test plan
bash test fl_math_fixed_point --cpp— green (1/1 passed, 17/17 build steps, 0.12s test time)FL_TEST_CASElost: the same 12 test cases run from the new filebash test --cppmatrixFollow-up
This is PR 1 of 8 for #3130. Remaining extractions (per the issue):
fixed_point_bounds.h(shared header — the keystone for cross-file dependencies)fixed_point_constexpr.cppfixed_point_bit_exact.cppfixed_point_signed_types.cppfixed_point_u4x12_u8x8.cppfixed_point_u12x4_u16x16.cppfixed_point_u8x24_u24x8.cppfixed_point.cppafter final extraction)After #3130 closes, #3131 (
string.cpp× 9 PRs) and #3132 (AutoResearchRemote.cpp× 7 PRs) follow, all tracked by meta #3127.Refs #3130. Tracked by #3127.
Generated with Claude Code.
Summary by CodeRabbit