open-standards/wai/http-conformance/falsify/budget-raises.patch
2026-10-06 14:03:26 -04:00

15 lines
821 B
Diff

# must fail: abr_budget_not_raised_to_labelled_options abr_budget_not_raised_to_one_within
# the budget raises the choice to the lowest labelled option above it within the budget (abr::clamp_to_budget)
diff --git a/wai/wai-rs/src/http_binding/abr.rs b/wai/wai-rs/src/http_binding/abr.rs
index cc9cd96a..a0cb30b9 100644
--- a/wai/wai-rs/src/http_binding/abr.rs
+++ b/wai/wai-rs/src/http_binding/abr.rs
@@ -398,7 +398,7 @@ pub fn clamp_to_budget(s: &AbrState, choice: usize) -> (usize, Budget) {
match (0..=choice).rev().find(|&k| fig(k).is_some_and(|j| j <= b)) {
Some(k) if k == choice => (k, Budget::Within),
Some(k) => (k, Budget::Lowered),
- None => (0, Budget::Unmet),
+ None => ((choice + 1..n).find(|&k| fig(k).is_some_and(|j| j <= b)).unwrap_or(0), Budget::Unmet),
}
}