You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Numeric comparison covers the open-ended cases — assert_greater_than, assert_greater_or_equal_than, assert_less_than, assert_less_or_equal_than, assert_within_delta — but not the bounded one. Asserting "the duration was between 100 and 500 ms" or "the exit code is in the 4xx range" takes two assertions, which reports two results and two failure messages for one logical check.
Dates already have the bounded form: assert_date_within_range (src/assert/dates.sh). Numbers do not.
Inclusive bounds, matching assert_date_within_range — check that assertion first and mirror its semantics and argument order rather than choosing independently.
TDD: RED → GREEN → REFACTOR. Use /add-assertion if helpful.
Bash 3.0+ only: no printf -v, no +=, no declare -A, no [[ ]], no ${var,,}, no &>>.
Assertions are bare-named (assert_x), helpers are bashunit::-namespaced. Start every assertion with bashunit::assert::should_skip && return 0 and report through bashunit::assertion_failed / bashunit::assertion_passed, matching its neighbours in the same file.
Tests: mirror the src layout — tests/unit/assert/<file>_test.sh. There is no assert_fails; test failure output by comparing against print_failed_test, as the existing tests do.
Docs: add the entry to docs/assertions.md, then regenerate the bashunit doc acceptance snapshot (editing that file breaks it).
Update the assertion count in README.md ("It ships 73 assertions…" — currently already stale at 74) and add a CHANGELOG.md line under ## Unreleased.
Gates: make sa, make lint, ./bashunit tests/, ./bashunit --parallel tests/. Never run shfmt -w.
Problem
Numeric comparison covers the open-ended cases —
assert_greater_than,assert_greater_or_equal_than,assert_less_than,assert_less_or_equal_than,assert_within_delta— but not the bounded one. Asserting "the duration was between 100 and 500 ms" or "the exit code is in the 4xx range" takes two assertions, which reports two results and two failure messages for one logical check.Dates already have the bounded form:
assert_date_within_range(src/assert/dates.sh). Numbers do not.Proposal
assert_date_within_range— check that assertion first and mirror its semantics and argument order rather than choosing independently.assert_within_deltain perf(assert): compare assert_within_delta in fixed point, not via bc #979 (with thebc/awkfallback) instead of forkingbcper call.bashunit::assert_once(src/assert/once.sh) if implemented in terms of other assertions, so the count matches one assertion (Custom asserts: a composed assertion should count and report once #917).Acceptance criteria
assert_between 1 10 5passes;assert_between 1 10 11failsassert_between 1 10 1andassert_between 1 10 10both passassert_between 0.1 0.3 0.2min > maxis a usage error, not a silently always-failing assertionassert_not_betweenis the exact negation and is tested independentlybcfork on the common integer path (perf(assert): compare assert_within_delta in fixed point, not via bc #979 precedent) — the fork-budget acceptance tests must still passRepo checklist (agent)
/add-assertionif helpful.printf -v, no+=, nodeclare -A, no[[ ]], no${var,,}, no&>>.assert_x), helpers arebashunit::-namespaced. Start every assertion withbashunit::assert::should_skip && return 0and report throughbashunit::assertion_failed/bashunit::assertion_passed, matching its neighbours in the same file.bashunit::assert::usage_error, not compare against an empty string (feat(assert): a missing argument reports a failed assertion, not a usage error #983).tests/unit/assert/<file>_test.sh. There is noassert_fails; test failure output by comparing againstprint_failed_test, as the existing tests do.docs/assertions.md, then regenerate thebashunit docacceptance snapshot (editing that file breaks it).README.md("It ships 73 assertions…" — currently already stale at 74) and add aCHANGELOG.mdline under## Unreleased.make sa,make lint,./bashunit tests/,./bashunit --parallel tests/. Never runshfmt -w.