Skip to content

A-Assertions: Assert the assumptions the code relies on - #5

Merged
trigg770 merged 4 commits into
masterfrom
branch-A-Assertions
Sep 10, 2026
Merged

trigg770 merged 4 commits into
masterfrom
branch-A-Assertions

Conversation

@trigg770

Copy link
Copy Markdown
Owner

Increment: A-Assertions

  • Adds assert statements for assumptions one part of Ted makes about another, each with a message naming what guarantees it: Parser#parse, Storage#parseLine, the TaskList constructor, Ted#getResponse and MainWindow#handleUserInput.
  • Enables assertions for gradle run. Tests already run with them on.
  • User input is still checked with exceptions, since bad input is expected and must be reported even with assertions off.

🤖 Generated with Claude Code

trigg770 and others added 4 commits September 10, 2026 20:20
Several classes rely on a guarantee made elsewhere without saying so.
If a later change breaks one of these guarantees, the failure appears
far from its cause, as a confusing reply or a NullPointerException.

Let's state each assumption with an assert whose message names what
guarantees it:
* Parser.parse never sees blank input, as Ted skips it
* Storage.parseLine never sees a blank line, as load() skips them,
  and never reaches its default branch, as fieldCountFor accepts
  only T, D and E
* TaskList is never given null, as Storage.load() skips unreadable
  lines instead of adding null
* Ted always has a task list, as the constructor makes an empty one
  when loading fails
* MainWindow always has a Ted, as Main calls setTed before showing
  the window

Let's also enable assertions for gradle run, as Java ignores them by
default. Tests already run with assertions on.

Checks on user input stay as exceptions, because bad input is expected
and must be reported even with assertions off. For the same reason
there is no assert that an event ends after it starts: the parser
rejects such an event, but a hand-edited save file can still hold one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@trigg770
trigg770 merged commit f05a110 into master Sep 10, 2026
6 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