prejsx_math 0.1.0

A minimal math expression parser using only Rust's standard library
Documentation
use prejsx_math::eval_math;

#[test]
fn test_simple_addition() {
    let result = eval_math("1 + 2").unwrap();
    assert_eq!(result, 3.0);
}

#[test]
fn test_nested_expression() {
    let result = eval_math("2 * (3 + 1)").unwrap();
    assert_eq!(result, 8.0);
}

#[test]
fn test_negative_number() {
    let result = eval_math("-5 + 2").unwrap();
    assert_eq!(result, -3.0);
}

#[test]
fn test_whitespace_handling() {
    let result = eval_math("  1 +   2 * ( 3 + 4 ) ").unwrap();
    assert_eq!(result, 15.0);
}

#[test]
fn test_invalid_expression() {
    let result = eval_math("1 +").unwrap_err();
    assert!(result.contains("Expected number"));
}