Skip to content

Make empty-duration handling explicit for parser compatibility - #135

Open
OskarEichler wants to merge 1 commit into
floraison:masterfrom
OskarEichler:codex/preserve-empty-duration-contract
Open

Make empty-duration handling explicit for parser compatibility#135
OskarEichler wants to merge 1 commit into
floraison:masterfrom
OskarEichler:codex/preserve-empty-duration-contract

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Make the existing empty-duration-as-zero behavior explicit in Duration.parse, including whitespace-only input. This preserves the contract used by Rufus without depending on a parser treating a failed match as successful.

This is a compatibility follow-up to floraison/raabro#13. With released Raabro 1.5.0, Fugit already returns a zero duration for empty input. With the proposed Raabro correction, that accidental acceptance disappears and Rufus's existing parse_duration example fails. Fugit should express its own accepted empty-duration policy.

Reproduction

require 'fugit'
Fugit::Duration.parse('').to_sec # intended existing result: 0

Using the corrected Raabro branch without this change returns nil instead. Rufus::Scheduler.parse_duration('') then raises, contradicting the existing Rufus expectation of 0.0.

Verification

  • rbenv Ruby 4.0.6, TZ=UTC. Existing Fugit master suite: 1,524 tests, 3,379 assertions, zero failures, one pending.
  • Sixteen external checks cover empty/space/newline inputs, plain/ISO/stricter options and preservation of original input/options. Invalid nonempty input still returns nil.
  • Combined release-based Fugit changes: 1,517 existing examples, zero failures, one pending, plus 998 focused checks with the restored empty-duration contract.
  • Rufus's existing parser suite: 37 examples, zero failures, including its empty-string expectation. The full 328-example Rufus integration suite is still running; no full-suite pass is claimed here.
  • Packaging, syntax and whitespace checked. Combined source retains the same 18 pre-existing Lint warnings; no new warnings.

Breaking changes and limitations

No intended breaking change: this preserves released behavior across the parser correction. Empty durations remain zero; invalid nonempty durations remain invalid. No dependency/version upgrades or test additions/modifications are included. Reproduction scripts stayed outside repositories under the task's no-new-tests policy. Other Ruby/platform combinations await upstream CI. No production execution. Prepared with Codex assistance.

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