File: ez.rs

package info (click to toggle)
rust-fasteval 0.2.4-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 952 kB
  • sloc: python: 14; makefile: 8
file content (11 lines) | stat: -rw-r--r-- 494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
use fasteval::{ez_eval, Error};

use std::collections::BTreeMap;

#[test]
fn ez() {
    assert_eq!(ez_eval("3+3-3/3", &mut BTreeMap::<String,f64>::new()), Ok(5.0));
    assert_eq!(ez_eval("3abc+3-3/3", &mut BTreeMap::<String,f64>::new()), Err(Error::UnparsedTokensRemaining("abc+3-3/3".to_string())));
    assert_eq!(ez_eval("z+z-z/z", &mut {let mut m=BTreeMap::<String,f64>::new(); m.insert("x".to_string(),1.0); m.insert("y".to_string(),2.0); m.insert("z".to_string(),3.0); m}), Ok(5.0));
}