From 95902a788969b515c322fe62fe6ada1820721384 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Tue, 25 Aug 2026 09:36:36 -0500 Subject: [PATCH] Delete an assertion that could never fail, and say what guards instead ConversionViewModelProbeFailureTest's pickedProbe() helper held: 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. R26 filed this PLAUSIBLE on types read; it is measured now. Flipping the line to assertNotNull failed 3 of the 4 tests in the class -- three, because pickedProbe() has three callers, which is also why a dead line here was worth removing rather than shrugging at: it read as coverage in a helper the whole class depends on. Deleted rather than replaced. There is 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 that, so the next reader does not re-add the guard the predicate already is. This is the ninth vacuous assertion this line of work has turned up, and the pattern is consistent: they hide in helpers, they pass, and they look like care. The suite is green before and after, which is exactly the point -- deleting a dead assertion cannot change a result, and if it had, the line was not dead. Closes #35. --- .../convert/ConversionViewModelProbeFailureTest.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/test/java/org/libremediaconverter/convert/ConversionViewModelProbeFailureTest.kt b/app/src/test/java/org/libremediaconverter/convert/ConversionViewModelProbeFailureTest.kt index 9bfe5b9..2aa69ac 100644 --- a/app/src/test/java/org/libremediaconverter/convert/ConversionViewModelProbeFailureTest.kt +++ b/app/src/test/java/org/libremediaconverter/convert/ConversionViewModelProbeFailureTest.kt @@ -140,10 +140,16 @@ class ConversionViewModelProbeFailureTest { private fun pickedProbe(): InputProbe? { val viewModel = ConversionViewModel(app, Dispatchers.Unconfined) viewModel.onInputPicked(INPUT) + // The predicate is the guard, and it is the only one needed. It requires `Ready`, so a + // pick that ended in `Failed` never satisfies it and `awaitState` fails on its timeout + // naming what it was waiting for -- "Ready with a probe" -- which says more than a + // separate assertion could. A `ready as? ConversionState.Failed` check used to sit here + // and was dead: `Ready` and `Failed` are sibling subtypes of one sealed interface, so + // the cast was always null and the assertNull could never fire. Measured, not assumed -- + // flipping it to assertNotNull failed all three callers of this helper. 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)) return (ready as ConversionState.Ready).input.probe }