Delete an assertion that could never fail, and say what guards instead #103

Merged
JMR-dev merged 2 commits from fix/dead-assertion-probe-test into main 2026-08-25 15:21:18 +00:00
JMR-dev commented 2026-08-25 14:36:39 +00:00 (Migrated from github.com)

Closes #35 (R26 — filed PLAUSIBLE on types read, measured here).

val ready = awaitState(viewModel.state, "Ready with a probe") {
    it is ConversionState.Ready && it.input.probe != null
}
assertNull("nothing here should reach a terminal failure", (ready as? ConversionState.Failed))

The predicate requires Ready. Ready and Failed are sibling subtypes of one sealed interface, so ready as? Failed is always null and the assertNull could never fire.

Measured, not reasoned

Flipping the line to assertNotNull failed 3 of the 4 tests in the class — three, because pickedProbe() has three callers. That's also why it was worth removing rather than shrugging at: it read as coverage inside a helper the whole class depends on.

Deleted rather than replaced

There's nothing for a live assertion to add. A pick that ended in Failed never satisfies the predicate, so awaitState fails on its timeout naming what it was waiting for — "Ready with a probe" — which is a better failure message than the assertion would have produced. The comment now says so, so the next reader doesn't re-add the guard the predicate already is.

Note

The suite is green before and after, which is the point: deleting a dead assertion cannot change a result, and if it had, the line wasn't dead.

This is the ninth vacuous assertion this line of work has surfaced, and they're consistent in shape — they hide in helpers, they pass, and they look like care.

Closes #35 (R26 — filed `PLAUSIBLE` on types read, **measured here**). ```kotlin val ready = awaitState(viewModel.state, "Ready with a probe") { it is ConversionState.Ready && it.input.probe != null } assertNull("nothing here should reach a terminal failure", (ready as? ConversionState.Failed)) ``` The predicate requires `Ready`. `Ready` and `Failed` are sibling subtypes of one sealed interface, so `ready as? Failed` is **always null** and the `assertNull` could never fire. ## Measured, not reasoned Flipping the line to `assertNotNull` **failed 3 of the 4 tests** in the class — three, because `pickedProbe()` has three callers. That's also why it was worth removing rather than shrugging at: it read as coverage inside a helper the whole class depends on. ## Deleted rather than replaced There's nothing for a live assertion to add. A pick that ended in `Failed` never satisfies the predicate, so `awaitState` fails on its timeout **naming what it was waiting for** — *"Ready with a probe"* — which is a better failure message than the assertion would have produced. The comment now says so, so the next reader doesn't re-add the guard the predicate already is. ## Note The suite is green before and after, which is the point: **deleting a dead assertion cannot change a result, and if it had, the line wasn't dead.** This is the ninth vacuous assertion this line of work has surfaced, and they're consistent in shape — they hide in helpers, they pass, and they look like care.
Sign in to join this conversation.