Skip to content

Commit

Permalink
Add separate test of validate_with_extension_closure
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Mar 18, 2024
1 parent 777e8e1 commit 42a7d05
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions quantinuum-hugr/src/extension/infer/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,26 @@ fn test_cfg_loops() -> Result<(), Box<dyn Error>> {
Ok(())
}

#[test]
#[cfg(feature = "extension_inference")]
fn test_validate_with_closure() -> Result<(), Box<dyn Error>> {
let hugr = make_looping_cfg(
ExtensionSet::new(),
ExtensionSet::singleton(&A),
ExtensionSet::singleton(&B),
)?;
let soln = infer_extensions(&hugr)?;
hugr.validate_with_extension_closure(soln, &PRELUDE_REGISTRY)?;
let mut hugr = hugr.clone();
assert_matches!(
hugr.validate(&PRELUDE_REGISTRY),
Err(ValidationError::ExtensionError(_))
);
hugr.update_validate(&PRELUDE_REGISTRY)?; // Solution written in, hence:
hugr.validate(&PRELUDE_REGISTRY)?;
Ok(())
}

#[test]
/// A control flow graph consisting of an entry node and a single block
/// which adds a resource and links to both itself and the exit node.
Expand Down

0 comments on commit 42a7d05

Please sign in to comment.