diff --git a/src/app/logic/calc.rs b/src/app/logic/calc.rs index cf7030c..792553c 100644 --- a/src/app/logic/calc.rs +++ b/src/app/logic/calc.rs @@ -762,15 +762,17 @@ fn fn_of_fn() { grid.set_cell("B0", 1.); grid.set_cell("C0", "=A0+B0".to_string()); grid.set_cell("D0", "=C0*2".to_string()); + + let cell = grid.get_cell("D0"); + assert!(cell.is_some()); - if let Some(cell) = grid.get_cell("D0") { + if let Some(cell) = cell { let res = grid.evaluate(&cell.to_string()); assert!(res.is_ok()); assert_eq!(res.unwrap(), (6.).into()); return; } - panic!("Cell not found"); } // Two cells that have a circular dependency to solve for a value @@ -780,12 +782,14 @@ fn circular_reference_cells() { grid.set_cell("A0", "=B0".to_string()); grid.set_cell("B0", "=A0".to_string()); - if let Some(cell) = grid.get_cell("A0") { + let cell = grid.get_cell("A0"); + assert!(cell.is_some()); + + if let Some(cell) = cell { let res = grid.evaluate(&cell.to_string()); assert!(res.is_err()); return; } - panic!("Cell not found"); } #[test] diff --git a/src/app/logic/ctx.rs b/src/app/logic/ctx.rs index 86033fe..f71fb70 100644 --- a/src/app/logic/ctx.rs +++ b/src/app/logic/ctx.rs @@ -188,7 +188,14 @@ impl<'a> Context for CallbackContext<'a> { return None; } - e => panic!("> Error {e}\n> Equation: '{eq}'"), + e => { + let msg = format!("> Error {e}\n> Equation: '{eq}'"); + #[cfg(debug_assertions)] + panic!("{msg}"); + + #[cfg(not(debug_assertions))] + eprintln!(msg) + }, } } } diff --git a/src/app/screen.rs b/src/app/screen.rs index 0e82aba..1519783 100644 --- a/src/app/screen.rs +++ b/src/app/screen.rs @@ -142,7 +142,7 @@ fn fit_cells() { app.vars.insert("height".to_string(), 1.to_string()); let (x,y) = app.screen.how_many_cells_fit_in(&prelude::Rect::new(0, 0, 181, 14), &app.vars); - assert_eq!(x, 18); + assert_eq!(x, 19); assert_eq!(y, 14); } @@ -156,7 +156,7 @@ fn scroll() { // We have to check how many cells fit, because screen learns the width // of the area by rumour here. let (x,y) = app.screen.how_many_cells_fit_in(&prelude::Rect::new(0, 0, 181, 14), &app.vars); - assert_eq!(x, 18); + assert_eq!(x, 19); assert_eq!(y, 14); // we aren't scrolled at all yet