Skip to content

test: add regression tests for list_swap, swap_columns, lu_factor#1954

Open
junhinhow wants to merge 3 commits intoBelfrySCAD:masterfrom
junhinhow:feat/add-missing-tests
Open

test: add regression tests for list_swap, swap_columns, lu_factor#1954
junhinhow wants to merge 3 commits intoBelfrySCAD:masterfrom
junhinhow:feat/add-missing-tests

Conversation

@junhinhow
Copy link
Copy Markdown

Summary

  • Add regression test for list_swap() with 7 asserts covering basic swaps, same-index, strings, and nested lists
  • Add regression test for swap_columns() with 5 asserts covering 2x2, 3x3, and identity matrices
  • Add regression test for lu_factor() with reconstruction verification for 2x2, 3x3, and identity matrices
  • Achieves 100% function test coverage (855/855, up from 99.65%)

Test plan

  • All 3 test functions pass in OpenSCAD without errors
  • No ECHO output produced
  • Verified with func_coverage.py that coverage is now 100%

🤖 Generated with Claude Code

Add test coverage for the list_swap() function (lists.scad) which was
added in commit 42ad387 but had no corresponding test.

Tests cover:
- Basic swap of two elements by index
- Swap with same index (no-op)
- Swap with string elements
- Swap first/last elements
- Swap symmetry (i,j == j,i)
- Swap with nested list elements

This brings list_swap() into the regression test suite, improving
overall coverage from 99.65% toward 100%.

Ref: BelfrySCAD#231
Add test coverage for the swap_columns() function (linalg.scad) which
was added in commit c461031 but had no corresponding test.

Tests cover:
- Swap non-adjacent columns in a 3x5 matrix
- Swap first and last columns
- Same-index swap (identity/no-op)
- Swap on a 2x2 matrix
- Swap on identity matrix produces permutation matrix

Ref: BelfrySCAD#231
Add test coverage for the lu_factor() function (linalg.scad) which
was added in commit 0678929 but had no corresponding test.

Tests verify the LU decomposition property:
  select(A, perm) == transpose(LT) * U

Cases covered:
- 2x2 matrix: basic factorization and reconstruction
- 3x3 matrix: non-trivial pivoting with reconstruction
- Identity matrix: decomposition preserves identity

This is the last uncovered public function in BOSL2, bringing
test coverage to 855/855 (100%).

Ref: BelfrySCAD#231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant