Skip to content

refactor(tests): extract fixed_point_constexpr.cpp (part of #3130, stacked on #3135) - #3136

Closed
zackees wants to merge 2 commits into
feat/3130-fixed-point-misc-extractfrom
feat/3130-fixed-point-constexpr-extract
Closed

zackees wants to merge 2 commits into
feat/3130-fixed-point-misc-extractfrom
feat/3130-fixed-point-constexpr-extract

Conversation

@zackees

@zackees zackees commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Second extraction in the tests/fl/math/fixed_point.cpp split tracked by #3130 (meta #3127). Moves the constexpr validation section into its own file.

Stacked on PR #3135 — depends on the check_test_file_pairing.py sibling-split allowance introduced there. Once #3135 merges to master, this PR can be retargeted/rebased to master.

Content moved into fixed_point_constexpr.cpp (343 LOC):

  • 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 computation results)
  • 23 constexpr_*_check<T>(...) helper templates that the test cases use exclusively
  • constexpr_raw_check<T>(...) helper (was at original line 122, only used by these tests)

The section header // Concrete Bit-Exact Tests (All Types) at original lines 798-802 stays in fixed_point.cpp — it now correctly introduces the bit-exact tests (the constexpr tests were mis-grouped under that header anyway).

LOC delta:

Test plan

Follow-up

PR 2 of 8 for #3130. Remaining extractions:

  • fixed_point_bit_exact.cpp (next, lines 1131-1970 in original)
  • fixed_point_signed_types.cpp (depends on the bounds header — needs the keystone bounds.h extraction)
  • fixed_point_bounds.h (the shared header — keystone for the type-specific tests)
  • fixed_point_u4x12_u8x8.cpp
  • fixed_point_u12x4_u16x16.cpp
  • fixed_point_u8x24_u24x8.cpp
  • (delete original fixed_point.cpp after final extraction)

Refs #3130. Tracked by #3127. Stacked on #3135.

Generated with Claude Code.

zackees and others added 2 commits June 15, 2026 19:35
…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]>
…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]>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: eb3c9cf6-d613-4908-9c83-c65d6f81d958

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3130-fixed-point-constexpr-extract

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 16, 2026
@zackees
zackees force-pushed the feat/3130-fixed-point-misc-extract branch from 29dcda2 to 786dcaa Compare June 16, 2026 04:36
@zackees
zackees deleted the branch feat/3130-fixed-point-misc-extract June 16, 2026 04:37
@zackees zackees closed this Jun 16, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 16, 2026
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
zackees added a commit that referenced this pull request Jun 16, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant