Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cyclic graph, doc failure #228

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,22 @@ mod test {
Ok(())
}

#[test]
fn test_cyclic() -> Result<(), HugrError> {
let mut h = Hugr::new(NodeType::pure(ops::DFG {
signature: FunctionType::new(type_row![QB_T], type_row![QB_T]),
}));
let input = h.add_op_with_parent(h.root(), ops::Input::new(type_row![QB_T]))?;
let output = h.add_op_with_parent(h.root(), ops::Output::new(type_row![QB_T]))?;
let cx = h.add_op_with_parent(h.root(), cx_gate())?;
h.connect(input, 0, cx, 0)?;
h.connect(cx, 0, output, 0)?;
h.connect(cx, 1, cx, 1)?;
// TODO FIXME We should get an error here, but this passes ATM :-(
h.validate().unwrap();
Ok(())
}

#[test]
/// A wire with no resource requirements is wired into a node which has
/// [A,BOOL_T] resources required on its inputs and outputs. This could be fixed
Expand Down