Skip to content

Commit

Permalink
test DescendantsGraph imls
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Nov 18, 2024
1 parent 23a6d37 commit 7fc6306
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hugr-core/src/hugr/views/descendants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub(super) mod test {
use rstest::rstest;

use crate::extension::PRELUDE_REGISTRY;
use crate::IncomingPort;
use crate::{
builder::{Container, Dataflow, DataflowSubContainer, HugrBuilder, ModuleBuilder},
type_row,
Expand Down Expand Up @@ -222,6 +223,7 @@ pub(super) mod test {
let (hugr, def, inner) = make_module_hgr()?;

let region: DescendantsGraph = DescendantsGraph::try_new(&hugr, def)?;
let def_io = region.get_io(def).unwrap();

assert_eq!(region.node_count(), 7);
assert!(region.nodes().all(|n| n == def
Expand All @@ -237,11 +239,21 @@ pub(super) mod test {
.into()
)
);

let inner_region: DescendantsGraph = DescendantsGraph::try_new(&hugr, inner)?;
assert_eq!(
inner_region.inner_function_type(),
Some(Signature::new(type_row![NAT], type_row![NAT]))
);
assert_eq!(inner_region.node_count(), 3);
assert_eq!(inner_region.children(inner).count(), 2);
assert_eq!(inner_region.node_connections(inner, def_io[1]).count(), 0);
assert_eq!(
inner_region
.linked_ports(inner, IncomingPort::from(0))
.count(),
0
);

Ok(())
}
Expand Down

0 comments on commit 7fc6306

Please sign in to comment.