fix #2
This commit is contained in:
29
src/main.rs
29
src/main.rs
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user