Skip to content

Commit

Permalink
Test 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 575a687
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions quantinuum-hugr/src/extension/infer/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ use crate::builder::{
use crate::extension::prelude::QB_T;
use crate::extension::ExtensionId;
use crate::extension::{prelude::PRELUDE_REGISTRY, ExtensionSet};
use crate::hugr::{Hugr, HugrMut, HugrView, NodeType};
use crate::hugr::{Hugr, HugrMut, HugrView, NodeType, ValidationError};
use crate::macros::const_extension_ids;
use crate::ops::custom::{ExternalOp, OpaqueOp};
use crate::ops::{self, dataflow::IOTrait};
use crate::ops::{LeafOp, OpType};
#[cfg(feature = "extension_inference")]
use crate::{
builder::test::closed_dfg_root_hugr,
hugr::validate::ValidationError,
ops::{dataflow::DataflowParent, handle::NodeHandle},
};

Expand Down Expand Up @@ -433,7 +432,15 @@ fn extension_adding_sequence() -> Result<(), Box<dyn Error>> {
for (src, tgt) in nodes.into_iter().tuple_windows() {
hugr.connect(src, 0, tgt, 0);
}
hugr.update_validate(&PRELUDE_REGISTRY)?;

let soln = infer_extensions(&hugr)?;
hugr.validate_with_extension_closure(soln, &PRELUDE_REGISTRY)?;
assert_matches!(
hugr.validate(&PRELUDE_REGISTRY),
Err(ValidationError::ExtensionError(_))
);
hugr.update_validate(&PRELUDE_REGISTRY)?; // Writes solution into Hugr
hugr.validate(&PRELUDE_REGISTRY)?;
Ok(())
}

Expand Down

0 comments on commit 575a687

Please sign in to comment.