Skip to content

refactor(tests): extract fixed_point_u12x4_u16x16.cpp (part of #3130, stacked on #3139) - #3142

Closed
zackees wants to merge 5 commits into
feat/3130-fixed-point-u4x12-u8x8-extractfrom
feat/3130-fixed-point-u12x4-u16x16-extract
Closed

zackees wants to merge 5 commits into
feat/3130-fixed-point-u4x12-u8x8-extractfrom
feat/3130-fixed-point-u12x4-u16x16-extract

Conversation

@zackees

@zackees zackees commented Jun 16, 2026

Copy link
Copy Markdown
Member

Fifth extraction for #3130. Moves the u12x4 + u16x16 unsigned-type tests into their own 935 LOC file. Both share a section because the u16x16 sub-section defines local check_near() overloads and tol()/smooth_tol()/rt_tol() constexpr helpers used only within these two type sections.

Stacked on: #3139 → #3138 → #3136 → #3135.

LOC delta:

  • tests/fl/math/fixed_point.cpp: 3,404 → 2,492 LOC
  • tests/fl/math/fixed_point_u12x4_u16x16.cpp (new): 935 LOC

Test plan:

  • bash test fl_math_fixed_point --cpp — green (1/1 passed, 0.39s test time, 44.6s build)
  • No FL_TEST_CASE lost
  • CI

PR 5 of 8 for #3130. Refs #3130. Tracked by #3127.

Generated with Claude Code.

zackees and others added 5 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]>
…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]>
…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]>
…t.cpp (part of #3130)

Fifth extraction in #3130. Moves the u12x4 + u16x16 unsigned type tests
into their own file. Both share a section because the section's u16x16
sub-section defines its own check_near() overloads and tol()/smooth_tol()
/rt_tol() helpers used only within these two type sections.

Content moved:
  - ~15 FL_TEST_CASE u12x4 tests (construction, addition, sub, mul, div,
    shifts, comparisons, math functions, advanced math, edge cases,
    precision)
  - ~30 FL_TEST_CASE u16x16 tests (default/float/from_raw construction,
    arithmetic, comparisons, mixed arithmetic, to_float, sqrt/rsqrt/pow,
    sqrt identity, floor/ceil/fract, min/max/mod, lerp/clamp/step/
    smoothstep, edge values, unsigned range, fractional precision)
  - tol(), smooth_tol(), rt_tol() constexpr helpers (only used in this
    section)
  - check_near(u16x16, ...) overloads (only used in this section)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.39s test time,
44.6s build).

fixed_point.cpp: 3,404 -> 2,492 LOC
fixed_point_u12x4_u16x16.cpp (new): 935 LOC

Stacked on feat/3130-fixed-point-u4x12-u8x8-extract (PR #3139).

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: 03463844-aee1-4f1a-9373-0abb734b9ffe

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-u12x4-u16x16-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-u4x12-u8x8-extract branch from f6fc82c to 2287ae5 Compare June 16, 2026 04:41
@zackees
zackees deleted the branch feat/3130-fixed-point-u4x12-u8x8-extract June 16, 2026 04:41
@zackees zackees closed this Jun 16, 2026
zackees added a commit that referenced this pull request Jun 16, 2026
….cpp (part of #3130)

Sixth extraction in #3130. Moves the u8x24 + u24x8 unsigned type tests
into their own file.

Content moved:
  - ~12 FL_TEST_CASE u8x24 tests (construction, addition, sub, mul, div,
    scalar mul, shifts, comparisons, math functions, sqrt/rsqrt/pow,
    edge cases, complex expressions)
  - ~25 FL_TEST_CASE u24x8 tests (default/float/from_raw construction,
    arithmetic, comparisons, mixed arithmetic, to_float, sqrt/rsqrt/pow,
    sqrt identity, floor/ceil/fract, abs, min/max/mod, lerp/clamp/step/
    smoothstep, edge values, large value arithmetic)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.34s test time,
56s build).

fixed_point.cpp: 2,492 -> 1,643 LOC
fixed_point_u8x24_u24x8.cpp (new): 872 LOC

Stacked on feat/3130-fixed-point-u12x4-u16x16-extract (PR #3142).

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) (#3163)

Sixth extraction in #3130. Moves the u8x24 + u24x8 unsigned type tests
into their own file.

Content moved:
  - ~12 FL_TEST_CASE u8x24 tests (construction, addition, sub, mul, div,
    scalar mul, shifts, comparisons, math functions, sqrt/rsqrt/pow,
    edge cases, complex expressions)
  - ~25 FL_TEST_CASE u24x8 tests (default/float/from_raw construction,
    arithmetic, comparisons, mixed arithmetic, to_float, sqrt/rsqrt/pow,
    sqrt identity, floor/ceil/fract, abs, min/max/mod, lerp/clamp/step/
    smoothstep, edge values, large value arithmetic)

Tests pass: bash test fl_math_fixed_point --cpp (1/1, 0.34s test time,
56s build).

fixed_point.cpp: 2,492 -> 1,643 LOC
fixed_point_u8x24_u24x8.cpp (new): 872 LOC

Stacked on feat/3130-fixed-point-u12x4-u16x16-extract (PR #3142).

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]>
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 16, 2026
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