const CYCLIC_PROGRAM: &str = r#"
molecule A {
id: Int
primary_key: id
}
molecule B {
id: Int
primary_key: id
}
reaction AtoB {
when: A(a)
emit: B { id: a.id }
}
reaction BtoA {
when: B(b)
emit: A { id: b.id }
}
"#;
#[test]
fn cycle_in_reaction_graph_is_rejected() {
let result = thal::load_str(CYCLIC_PROGRAM);
let err = result.err().expect("expected verify error for A <-> B cycle");
let msg = err.to_string();
assert!(
msg.contains("cycle"),
"error should mention `cycle`, got: {msg}"
);
}
const ACYCLIC_PROGRAM: &str = r#"
molecule X {
id: Int
primary_key: id
}
molecule Y {
id: Int
primary_key: id
}
reaction XtoY {
when: X(x)
emit: Y { id: x.id }
}
"#;
#[test]
fn acyclic_chain_is_accepted() {
thal::load_str(ACYCLIC_PROGRAM).expect("acyclic program should load");
}