Skip to content

Commit cea0e7b

Browse files
committed
Add simple stupid test
1 parent 8ce4432 commit cea0e7b

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/qasm2/test_native.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import textwrap
33

44
import cirq
5-
import cirq.contrib
65
import cirq.testing
76
import cirq.contrib.qasm_import as qasm_import
87
import cirq.circuits.qasm_output as qasm_output
@@ -86,6 +85,18 @@ def generator(n_tests: int):
8685
"""
8786
)
8887

88+
yield textwrap.dedent(
89+
"""
90+
OPENQASM 2.0;
91+
include "qelib1.inc";
92+
93+
qreg q[2];
94+
95+
cu3(0.0, 0.6, 3.141591) q[0],q[1];
96+
97+
"""
98+
)
99+
89100
rgen = np.random.RandomState(128)
90101
for num in range(n_tests):
91102
# Generate a new instance:
@@ -117,3 +128,28 @@ def kernel():
117128
cirq.testing.assert_allclose_up_to_global_phase(
118129
cirq.unitary(old_circuit), cirq.unitary(cirq_circuit), atol=1e-8
119130
)
131+
132+
133+
def test_cu3_rewrite():
134+
prog = textwrap.dedent(
135+
"""
136+
OPENQASM 2.0;
137+
include "qelib1.inc";
138+
139+
qreg q[2];
140+
141+
cu3(0.0, 0.6, 3.141591) q[0],q[1];
142+
143+
"""
144+
)
145+
146+
@qasm2.main.add(qasm2.dialects.inline)
147+
def kernel():
148+
qasm2.inline(prog)
149+
150+
walk.Walk(RydbergGateSetRewriteRule(kernel.dialects)).rewrite(kernel.code)
151+
152+
new_qasm2 = qasm2.emit.QASM2().emit_str(kernel)
153+
154+
# simple-stupid test to see if the rewrite injected a bunch of new lines
155+
assert new_qasm2.count("\n") > prog.count("\n")

0 commit comments

Comments
 (0)