StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use super::{macros::*, *}; |
| 2 | |
| 3 | #[test] |
| 4 | fn test_context_predicate_eval() -> anyhow::Result<()> { |
| 5 | let predicate = id!("a") & id!("b") | eq!("c", "d"); |
| 6 | |
| 7 | let mut context = Context::default(); |
| 8 | context.set.insert("a"); |
| 9 | assert!(!predicate.eval(&context)); |
| 10 | |
| 11 | context.set.insert("b"); |
| 12 | assert!(predicate.eval(&context)); |
| 13 | |
| 14 | context.set.remove("b"); |
| 15 | context.map.insert("c", "x"); |
| 16 | assert!(!predicate.eval(&context)); |
| 17 | |
| 18 | context.map.insert("c", "d"); |
| 19 | assert!(predicate.eval(&context)); |
| 20 | |
| 21 | let predicate = !id!("a"); |
| 22 | assert!(predicate.eval(&Context::default())); |
| 23 | |
| 24 | Ok(()) |
| 25 | } |
| 26 |