Skip to content

test(math): add missing mod function tests and improve docs#1

Open
bejaratommy wants to merge 1 commit intomasterfrom
fix/add-mod-tests
Open

test(math): add missing mod function tests and improve docs#1
bejaratommy wants to merge 1 commit intomasterfrom
fix/add-mod-tests

Conversation

@bejaratommy
Copy link
Copy Markdown
Owner

Summary

Fixes Masterminds#458 (in Masterminds/sprig).

The mod function had no test coverage in numeric_test.go, despite being documented and implemented. The test file skipped from div/divf directly to mul/mulf, leaving mod untested.

Changes

  • numeric_test.go: Add TestMod covering:
    • Basic modulo with a remainder (10 % 3 = 1)
    • Even divisor, remainder is zero (10 % 2 = 0)
    • Divisor equals dividend (10 % 10 = 0)
    • General case (7 % 3 = 1)
  • docs/math.md: Expand the mod section with a concrete example and a note on argument ordering, which is non-obvious in piped template syntax.

Testing

$ go test ./... -run TestMod -v
=== RUN   TestMod
--- PASS: TestMod (0.00s)
PASS
ok  github.com/Masterminds/sprig/v3  0.299s

Note: TestRound has a pre-existing floating-point precision failure on the upstream master branch unrelated to this change.

The mod function was missing test coverage in numeric_test.go, even
though it was documented in docs/math.md. Add tests covering basic
modulo, even divisors, and equality cases.

Also expand the mod documentation to show a concrete example and
clarify argument ordering, which is non-obvious in piped template
syntax.

Fixes Masterminds#458

Signed-off-by: Tommy <tommy@bejarano.io>
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.

Missing Modulo tests

1 participant