Skip to content

Daily Test Coverage Improver - Add comprehensive tests for Permutation module - #19

Merged
dsyme merged 1 commit into
mainfrom
test-coverage/permutation-module-20251011-ea53c5b406696562
Oct 12, 2025
Merged

dsyme merged 1 commit into
mainfrom
test-coverage/permutation-module-20251011-ea53c5b406696562

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

This PR adds comprehensive unit tests for the Permutation module, which had 0% test coverage previously. The module provides functions for creating and manipulating permutations used in linear algebra operations.

Problems Found

  1. Permutation module had 0% test coverage - all permutation operations were untested
  2. Overall project coverage was low at 4.83% (99/2047 lines)

Actions Taken

  1. Created PermutationTests.fs with 39 comprehensive tests covering:

    • ofFreshArray/ofArray (9 tests): Creating permutations from arrays, validation, edge cases
    • sign (5 tests): Computing permutation sign (even/odd transpositions)
    • ofPairs (3 tests): Creating permutations from index mappings
    • swap (3 tests): Simple transposition operations
    • reversal (4 tests): Reversing index order
    • rotation (6 tests): Cyclic rotations with validation
    • identity (1 test): Identity permutation
    • inverse (6 tests): Computing and validating inverse permutations
    • Composition (2 tests): Testing algebraic properties
  2. Updated FsMath.Tests.fsproj to include the new test file

  3. All 171 tests pass (132 original + 39 new tests)

Test Coverage Results

Metric Before After Change
Overall Line Coverage 4.83% 6.59% +1.76%
Lines Covered 99/2047 135/2047 +36 lines
Total Tests 132 171 +39 tests
Permutation Module Coverage 0% 93.93% +93.93%

Permutation Module Details

  • Main module: 93.93% coverage (62/66 lines)
  • All core functions tested with edge cases
  • 4 uncovered lines are likely internal compiler-generated code

Replicating the Test Coverage Measurements

To replicate these measurements:

# Clean previous coverage
rm -rf ./coverage ./coverage-new

# Build the project
dotnet build

# Run tests with coverage (baseline on main)
git checkout main
dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj \
  --no-build \
  --collect:"XPlat Code Coverage" \
  --results-directory ./coverage \
  -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura

# Extract baseline metrics
BASELINE_FILE=$(find ./coverage -name "coverage.cobertura.xml" | head -n 1)
grep -oP 'line-rate="\K[^"]*' "$BASELINE_FILE" | head -n 1  # Should show 0.0483
grep -oP 'lines-covered="\K[^"]*' "$BASELINE_FILE" | head -n 1  # Should show 99

# Run tests with coverage (on this branch)
git checkout test-coverage/permutation-module-20251011
dotnet build
dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj \
  --no-build \
  --collect:"XPlat Code Coverage" \
  --results-directory ./coverage-new \
  -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura

# Extract new metrics
NEW_FILE=$(find ./coverage-new -name "coverage.cobertura.xml" | head -n 1)
grep -oP 'line-rate="\K[^"]*' "$NEW_FILE" | head -n 1  # Will show 0.0659
grep -oP 'lines-covered="\K[^"]*' "$NEW_FILE" | head -n 1  # Will show 135

# Verify test count increased
dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj --no-build | grep "Passed"  # Should show 171 tests

Possible Other Areas for Future Improvement

Based on the coverage report and dependency analysis, the following areas have 0% or very low coverage and could benefit from additional tests:

High Priority (Foundation - 0% coverage):

  1. MatrixModule.fs (130 lines, 0% coverage) - Matrix utility functions
  2. Algebra/Householder.fs (126 lines, 0% coverage) - Householder transformations for QR decomposition
  3. Algebra/LinearAlgebra.fs (partial coverage) - QR, LU decomposition, solving systems
  4. SIMDUtils.fs (0% coverage) - SIMD detection and utilities

Medium Priority (Advanced algorithms - 0% coverage):

  1. Algebra/SVD.fs - Singular Value Decomposition
  2. Algebra/EVD.fs - Eigenvalue Decomposition
  3. SpecialFunctions/Gamma.fs (partial coverage) - Gamma function and related special functions

Recommendation: The next logical area would be MatrixModule.fs as it provides utility functions that other modules depend on, similar to how VectorModule was tested in PR #10.


Execution Details (bash commands, web searches, web pages fetched)

Bash Commands Run:

  • git checkout -b test-coverage/permutation-module-20251011
  • dotnet build tests/FsMath.Tests/FsMath.Tests.fsproj
  • dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj --no-build (multiple times)
  • dotnet test tests/FsMath.Tests/FsMath.Tests.fsproj --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage-new
  • Coverage extraction and comparison using Python XML parsing
  • git add tests/FsMath.Tests/PermutationTests.fs tests/FsMath.Tests/FsMath.Tests.fsproj
  • git commit -m "Add comprehensive tests for Permutation module"

Web Searches:

None performed

Web Pages Fetched:

None fetched


AI generated by Daily Test Coverage Improver

AI generated by Daily Test Coverage Improver

- Added 39 new tests covering all Permutation module functions
- Achieved 93.93% coverage for Permutation module (62/66 lines)
- Overall project coverage improved from 4.83% to 6.59% (+1.76pp)
- Total test count: 132 -> 171 tests (+39)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@dsyme dsyme closed this Oct 11, 2025
@dsyme dsyme reopened this Oct 11, 2025
@dsyme
dsyme marked this pull request as ready for review October 12, 2025 12:41
@dsyme
dsyme merged commit 1dbf326 into main Oct 12, 2025
2 checks passed
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