Skip to content

Commit

Permalink
Add test of gate broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman committed Jan 31, 2024
1 parent fcc79df commit 6712183
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/python/qasm3/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,35 @@ def test_set_include_path(self):
expected = QuantumCircuit([Qubit()])
expected.x(0)
self.assertEqual(parsed, expected)

def test_gate_broadcast(self):
program = """
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q0;
qubit q1;
qubit[2] q2;
h q0;
cx q0, q1;
cx q0[0], q2;
cx q0, q2;
ccx q0[{1, 0}], q1, q2;
"""
parsed = qasm3.loads_experimental(program)
q0, q1, q2 = QuantumRegister(2, "q0"), Qubit(), QuantumRegister(2, "q2")
expected = QuantumCircuit(q0, [q1], q2)
expected.h(q0[0])
expected.h(q0[1])
#
expected.cx(q0[0], q1)
expected.cx(q0[1], q1)
#
expected.cx(q0[0], q2[0])
expected.cx(q0[0], q2[1])
#
expected.cx(q0[0], q2[0])
expected.cx(q0[1], q2[1])
#
expected.ccx(q0[1], q1, q2[0])
expected.ccx(q0[0], q1, q2[1])
self.assertEqual(parsed, expected)

0 comments on commit 6712183

Please sign in to comment.