hamelin_eval 0.11.1

Expression evaluation for Hamelin query language
Documentation
use crate::eval::environment::Environment;
use crate::eval::evaluator::eval;
use crate::value::Value;
use hamelin_lib::tree::builder::{and, or, ExpressionBuilder};
use hamelin_lib::tree::options::ExpressionTypeCheckOptions;
use hamelin_lib::type_check_expression;

#[test]
fn test_eval_boolean_operators() {
    let env = Environment::new();

    // Test AND
    let expr = type_check_expression(
        and(true, false).build(),
        ExpressionTypeCheckOptions::default(),
    )
    .output;
    let result = eval(&expr, &env).unwrap();
    assert_eq!(result, Value::Boolean(false));

    // Test OR
    let expr = type_check_expression(
        or(true, false).build(),
        ExpressionTypeCheckOptions::default(),
    )
    .output;
    let result = eval(&expr, &env).unwrap();
    assert_eq!(result, Value::Boolean(true));

    // Test AND with both true
    let expr = type_check_expression(
        and(true, true).build(),
        ExpressionTypeCheckOptions::default(),
    )
    .output;
    let result = eval(&expr, &env).unwrap();
    assert_eq!(result, Value::Boolean(true));

    // Test OR with both false
    let expr = type_check_expression(
        or(false, false).build(),
        ExpressionTypeCheckOptions::default(),
    )
    .output;
    let result = eval(&expr, &env).unwrap();
    assert_eq!(result, Value::Boolean(false));
}