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

15 lines
985 B
Diff

# must fail: abr_budget_not_applied abr_budget_unlabelled_choice depth_O10_budget_unlabelled_layer
# an unlabelled figure taken as zero joules (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..18d9cbfe 100644
--- a/wai/wai-rs/src/http_binding/abr.rs
+++ b/wai/wai-rs/src/http_binding/abr.rs
@@ -391,7 +391,7 @@ pub fn labelled_figure(joules_micro: u64, class: Option<&crate::energy_class::En
pub fn clamp_to_budget(s: &AbrState, choice: usize) -> (usize, Budget) {
let Some(b) = s.joule_budget_micro else { return (choice, Budget::NotSet) };
let n = s.option_bytes.len().max(choice + 1);
- let fig = |k: usize| if k < n { s.option_joules_micro.get(k).copied().flatten() } else { None };
+ let fig = |k: usize| if k < n { s.option_joules_micro.get(k).copied().flatten().or(Some(0)) } else { None };
if (0..n).all(|k| fig(k).is_none()) {
return (choice, Budget::NotApplied);
}