fsm-guards 0.1.1

Fuel-metered JSONLogic guard evaluation with per-call custom operators — forked from jsonlogic-rs
Documentation
use fsm_guards::apply;
use serde_json::json;

#[test]
fn equals_true() {
    assert_eq!(apply(&json!({"==": [1, 1]}), &json!({})).unwrap(), json!(true));
}

#[test]
fn equals_false() {
    assert_eq!(apply(&json!({"==": [1, 2]}), &json!({})).unwrap(), json!(false));
}

#[test]
fn var_lookup() {
    assert_eq!(
        apply(&json!({"var": "x"}), &json!({"x": 42})).unwrap(),
        json!(42)
    );
}

#[test]
fn and_true() {
    assert_eq!(
        apply(&json!({"and": [true, true]}), &json!({})).unwrap(),
        json!(true)
    );
}

#[test]
fn or_false() {
    assert_eq!(
        apply(&json!({"or": [false, false]}), &json!({})).unwrap(),
        json!(false)
    );
}