use super::*;
#[test]
fn test_subsumption_verification_soundness() {
let old_ast = serde_json::json!({
"abstract_spec": {
"invariants": {
"preconditions": ["pre_a", "pre_b"],
"postconditions": ["post_x"]
}
}
});
let compliant_new_ast = serde_json::json!({
"abstract_spec": {
"invariants": {
"preconditions": ["pre_a"],
"postconditions": ["post_x", "post_y"]
}
}
});
let res = verify_subsumption(&old_ast, &compliant_new_ast);
assert!(res.is_ok());
let report = res.unwrap();
assert!(report.pre_subsumed);
assert!(report.post_subsumed);
assert!(report.subsumption_valid);
let breaking_pre_ast = serde_json::json!({
"abstract_spec": {
"invariants": {
"preconditions": ["pre_a", "pre_c"],
"postconditions": ["post_x"]
}
}
});
assert!(verify_subsumption(&old_ast, &breaking_pre_ast).is_err());
let breaking_post_ast = serde_json::json!({
"abstract_spec": {
"invariants": {
"preconditions": ["pre_a"],
"postconditions": ["post_z"]
}
}
});
assert!(verify_subsumption(&old_ast, &breaking_post_ast).is_err());
}
#[test]
fn test_dynamic_baldwin_fiber_lifecycle() {
let ctx = crate::fiber::Context::root();
let fiber = ctx.create_fiber("test_fiber", vec!["effect_1".to_string()]).unwrap();
assert_eq!(fiber.get_state(), crate::fiber::FiberState::Pending);
augment_fiber(&ctx, "test_fiber", "effect_1").unwrap();
assert_eq!(fiber.get_state(), crate::fiber::FiberState::Active);
let split_res = split_fiber(&ctx, "test_fiber", &["effect_1"]);
assert!(split_res.is_ok());
exclude_fiber(&ctx, "test_fiber").unwrap();
assert!(ctx.get_fiber("test_fiber").is_none());
}