Skip to content

Commit

Permalink
test: add conditional classical test
Browse files Browse the repository at this point in the history
  • Loading branch information
qartik committed Apr 2, 2024
1 parent b9371fc commit ab17133
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_phirgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ def test_conditional_barrier() -> None:
}


def test_simple_cond_classical() -> None:
"""Ensure conditional classical operation are correctly generated."""
circ = get_qasm_as_circuit(QasmFile.simple_cond)
phir = json.loads(pytket_to_phir(circ))
assert phir["ops"][-6] == {"//": "IF ([c[0]] == 1) THEN SetBits(1) z[0];"}
assert phir["ops"][-5] == {
"block": "if",
"condition": {"cop": "==", "args": [["c", 0], 1]},
"true_branch": [{"cop": "=", "returns": [["z", 0]], "args": [1]}],
}


def test_nested_bitwise_op() -> None:
"""From https://github.com/CQCL/pytket-phir/issues/133 ."""
circ = Circuit(4)
Expand Down

0 comments on commit ab17133

Please sign in to comment.