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: fix some bad assert_matches #1006

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions hugr/src/hugr/rewrite/outline_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ mod test {

let [left, right]: [Node; 2] = h.output_neighbours(head).collect_vec().try_into().unwrap();
let r = h.apply_rewrite(OutlineCfg::new([left, right, head]));
assert_matches!(r, Err(OutlineCfgError::MultipleExitNodes(a,b)) => HashSet::from([a,b]) == HashSet::from_iter([left, right, head]));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm, ooops

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is now correct?

Copy link
Contributor Author

@acl-cqc acl-cqc May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, using HashSet::from([left, right, head]) in the new RHS now fails, as one would hope

assert_matches!(r, Err(OutlineCfgError::MultipleExitNodes(a,b)) => assert_eq!(HashSet::from([a,b]), HashSet::from_iter([left, right])));
assert_eq!(h, backup);

let r = h.apply_rewrite(OutlineCfg::new([left, right, merge]));
assert_matches!(r, Err(OutlineCfgError::MultipleEntryNodes(a,b)) => HashSet::from([a,b]) == HashSet::from([left, right]));
assert_matches!(r, Err(OutlineCfgError::MultipleEntryNodes(a,b)) => assert_eq!(HashSet::from([a,b]), HashSet::from([left, right])));
assert_eq!(h, backup);
}

Expand Down
2 changes: 1 addition & 1 deletion hugr/src/hugr/rewrite/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ mod test {
mu_new: vec![bad_order_edge.clone()],
..rep.clone()
}),
ReplaceError::BadEdgeKind(_, e) => e == bad_order_edge
ReplaceError::BadEdgeKind(_, e) => assert_eq!(e, bad_order_edge)
);
let op = OutgoingPort::from(0);
let (tgt, ip) = h.linked_inputs(cond.node(), op).next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion hugr/src/hugr/validate/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fn nested_typevars() -> Result<(), Box<dyn std::error::Error>> {
);
assert_matches!(build(Type::new_var_use(0, OUTER_BOUND)).unwrap_err(),
BuildError::InvalidHUGR(ValidationError::SignatureError { cause: SignatureError::TypeVarDoesNotMatchDeclaration { actual, cached }, .. }) =>
actual == INNER_BOUND.into() && cached == OUTER_BOUND.into());
{assert_eq!(actual, INNER_BOUND.into()); assert_eq!(cached, OUTER_BOUND.into())});
Ok(())
}

Expand Down