fission-core 0.2.0

Core runtime, state, actions, effects, resources, input, and UI model for Fission
Documentation
use crate::env::{Env, RuntimeState};
use crate::lowering::LoweringContext;
use crate::ui::traits::Lower;
use crate::ui::widgets::clip::Clip;
use crate::ui::widgets::container::Container;
use fission_ir::{LayoutOp, Op};

#[test]
fn test_clip_lowering() {
    let env = Env::default();
    let runtime_state = RuntimeState::default();

    let clip = Clip {
        path: Some("M 0 0 L 100 0 L 100 100 L 0 100 Z".into()),
        child: Box::new(Container::default().into_node()),
        ..Default::default()
    };

    let mut cx = LoweringContext::new(&env, &runtime_state, None, None);
    let root_id = clip.lower(&mut cx);

    let node = cx.ir.nodes.get(&root_id).unwrap();
    if let Op::Layout(LayoutOp::Clip { path }) = &node.op {
        assert_eq!(path.as_deref(), Some("M 0 0 L 100 0 L 100 100 L 0 100 Z"));
    } else {
        panic!("Expected LayoutOp::Clip, got {:?}", node.op);
    }
}