From 3e8c48eefc0672bc4b833604be04489be23e10d7 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Fri, 22 May 2026 16:47:16 +0200 Subject: [PATCH] fix(wasm): call expect() directly instead of ok().expect() in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WASM binding's test module (added in B6) used `.ok().expect(...)` on the Result-returning constructors. clippy's ok_expect lint rejects this under the workspace's `-D warnings`, and the CI rust job lints wickra-wasm with --all-targets — so the branch would fail CI. Replace all seven `.ok().expect(...)` with `.expect(...)` directly; JsError implements Debug, so this compiles and gives a better panic message. clippy and fmt are now clean for wickra-wasm. --- bindings/wasm/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/wasm/src/lib.rs b/bindings/wasm/src/lib.rs index 304e44a2..b5bed4ec 100644 --- a/bindings/wasm/src/lib.rs +++ b/bindings/wasm/src/lib.rs @@ -662,7 +662,7 @@ mod tests { #[wasm_bindgen_test] fn sma_batch_reference_values() { // SMA(3) of [2, 4, 6, 8, 10] -> [NaN, NaN, 4, 6, 8]. - let mut sma = WasmSma::new(3).ok().expect("valid period"); + let mut sma = WasmSma::new(3).expect("valid period"); let out = sma.batch(&[2.0, 4.0, 6.0, 8.0, 10.0]); assert!(out.get_index(0).is_nan()); assert!(out.get_index(1).is_nan()); @@ -676,8 +676,8 @@ mod tests { let prices: Vec = (1..=60) .map(|i| 100.0 + (f64::from(i) * 0.3).sin() * 5.0) .collect(); - let batch = WasmEma::new(14).ok().expect("valid").batch(&prices); - let mut ema = WasmEma::new(14).ok().expect("valid"); + let batch = WasmEma::new(14).expect("valid").batch(&prices); + let mut ema = WasmEma::new(14).expect("valid"); for (i, &p) in prices.iter().enumerate() { let b = batch.get_index(i as u32); match ema.update(p) { @@ -690,7 +690,7 @@ mod tests { #[wasm_bindgen_test] fn rsi_pure_uptrend_yields_100() { let prices: Vec = (1..=20).map(f64::from).collect(); - let out = WasmRsi::new(14).ok().expect("valid").batch(&prices); + let out = WasmRsi::new(14).expect("valid").batch(&prices); for i in 14..prices.len() { assert_eq!(out.get_index(i as u32), 100.0); } @@ -707,13 +707,13 @@ mod tests { #[wasm_bindgen_test] fn batch_rejects_unequal_lengths() { - let mut atr = WasmAtr::new(14).ok().expect("valid"); + let mut atr = WasmAtr::new(14).expect("valid"); assert!(atr.batch(&[1.0, 2.0], &[1.0], &[1.0, 2.0]).is_err()); - let mut stoch = WasmStoch::new(14, 3).ok().expect("valid"); + let mut stoch = WasmStoch::new(14, 3).expect("valid"); assert!(stoch .batch(&[1.0, 2.0, 3.0], &[1.0], &[1.0, 2.0, 3.0]) .is_err()); - let mut mfi = WasmMfi::new(14).ok().expect("valid"); + let mut mfi = WasmMfi::new(14).expect("valid"); assert!(mfi .batch(&[1.0, 2.0], &[1.0, 2.0], &[1.0, 2.0], &[1.0]) .is_err());