This commit is contained in:
2025-11-11 08:56:56 -07:00
parent 40f5c3d535
commit d22c053ce0
7 changed files with 229 additions and 147 deletions

View File

@@ -1,30 +1,6 @@
mod app;
mod ctx;
use crate::app::{app::App, calc::{Grid}};
#[test]
fn test_math() {
use evalexpr::*;
let mut grid = Grid::new();
grid.set_cell("A0", 2.);
grid.set_cell("B0", 1.);
grid.set_cell("C0", "=A0+B0".to_string());
assert_eq!(eval("1+2").unwrap(), Value::Int(3));
let cell_text = &grid.get_cell("C0");
if let Some(text) = cell_text {
if text.is_equation() {
println!("{}", text.as_raw_string());
let display = grid.evaluate(&text.as_raw_string());
assert_eq!(display, Some(3.));
return;
}
}
panic!("Should've found the value and returned");
}
use crate::app::{app::App};
fn main() -> Result<(), std::io::Error> {
let term = ratatui::init();
@@ -36,6 +12,9 @@ fn main() -> Result<(), std::io::Error> {
app.grid.set_cell("C0", "Fruit".to_string());
app.grid.set_cell("C1", "=A1+B1".to_string());
app.grid.set_cell("D0", "x2".to_string());
app.grid.set_cell("D1", "=C1*2".to_string());
let res = app.run(term);
ratatui::restore();
return res;