Skip to content

Commit

Permalink
Ignore const fold test
Browse files Browse the repository at this point in the history
  • Loading branch information
aborgna-q committed Aug 29, 2024
1 parent 602fa86 commit 7c0c892
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions hugr-passes/src/const_fold/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ fn test_big() {
}

#[test]
#[cfg_attr(
feature = "extension_inference",
ignore = "inference fails for test graph, it shouldn't"
)]
#[cfg(ignore = "Waiting for `unwrap` operation")]
// TODO: https://github.com/CQCL/hugr/issues/1486
fn test_list_ops() -> Result<(), Box<dyn std::error::Error>> {
use hugr_core::std_extensions::collections::{self, ListOp, ListValue};

Expand All @@ -137,28 +135,40 @@ fn test_list_ops() -> Result<(), Box<dyn std::error::Error>> {
collections::EXTENSION.to_owned(),
])
.unwrap();
let list: Value = ListValue::new(BOOL_T, [Value::false_val()]).into();
let mut build =
DFGBuilder::new(Signature::new(type_row![], vec![list.get_type().clone()])).unwrap();

let list_wire = build.add_load_const(list.clone());

let pop = build.add_dataflow_op(
ListOp::pop.with_type(BOOL_T).to_extension_op(&reg).unwrap(),
[list_wire],
)?;

let push = build.add_dataflow_op(
ListOp::push
.with_type(BOOL_T)
.to_extension_op(&reg)
.unwrap(),
pop.outputs(),
)?;
let mut h = build.finish_hugr_with_outputs(push.outputs(), &reg)?;
let base_list: Value = ListValue::new(BOOL_T, [Value::false_val()]).into();
let mut build = DFGBuilder::new(Signature::new(
type_row![],
vec![base_list.get_type().clone()],
))
.unwrap();

let list = build.add_load_const(base_list.clone());

let [list, maybe_elem] = build
.add_dataflow_op(
ListOp::pop.with_type(BOOL_T).to_extension_op(&reg).unwrap(),
[list],
)?
.outputs_arr();

// FIXME: Unwrap the Option<BOOL_T>
let elem = maybe_elem;

let [list] = build
.add_dataflow_op(
ListOp::push
.with_type(BOOL_T)
.to_extension_op(&reg)
.unwrap(),
[list, elem],
)?
.outputs_arr();

let mut h = build.finish_hugr_with_outputs([list], &reg)?;

constant_fold_pass(&mut h, &reg);

assert_fully_folded(&h, &list);
assert_fully_folded(&h, &base_list);
Ok(())
}

Expand Down

0 comments on commit 7c0c892

Please sign in to comment.