Skip to content

Commit

Permalink
test: Fix unconnected ports in extension test (#1010)
Browse files Browse the repository at this point in the history
While trying to separate out extension validation from the rest of
validation, I found that the graph here was invalid! The extension error
gets thrown before it starts complaining about all of the unconnected
outputs.
  • Loading branch information
croyzor committed May 8, 2024
1 parent 4409d1d commit 2ac1ebe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hugr/src/hugr/validate/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,19 +916,21 @@ mod extension_tests {

let all_rs = ExtensionSet::from_iter([XA, XB]);

let main_sig = FunctionType::new(type_row![], type_row![NAT])
let main_sig = FunctionType::new(type_row![NAT], type_row![NAT])
.with_extension_delta(all_rs.clone())
.into();

let mut main = module_builder.define_function("main", main_sig)?;

let [inp_wire] = main.input_wires_arr();

let [left_wire] = main
.dfg_builder(
FunctionType::new(type_row![], type_row![NAT]),
Some(XA.into()),
[],
)?
.finish_with_outputs([])?
.finish_with_outputs([inp_wire])?
.outputs_arr();

let [right_wire] = main
Expand All @@ -937,16 +939,16 @@ mod extension_tests {
Some(XB.into()),
[],
)?
.finish_with_outputs([])?
.finish_with_outputs([inp_wire])?
.outputs_arr();

let builder = main.dfg_builder(
FunctionType::new(type_row![NAT, NAT], type_row![NAT]),
Some(all_rs),
[left_wire, right_wire],
)?;
let [_left, _right] = builder.input_wires_arr();
let [output] = builder.finish_with_outputs([])?.outputs_arr();
let [left, _] = builder.input_wires_arr();
let [output] = builder.finish_with_outputs([left])?.outputs_arr();

main.finish_with_outputs([output])?;
let handle = module_builder.hugr().validate(&PRELUDE_REGISTRY);
Expand Down

0 comments on commit 2ac1ebe

Please sign in to comment.