Skip to content

Commit 264a9fb

Browse files
committed
Test nested kernels as well
1 parent 22934e9 commit 264a9fb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/qasm2/passes/test_unroll_if.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,30 @@ def main_unrolled():
4545
ast_unrolled = target.emit(main_unrolled)
4646

4747
qasm2.parse.pprint(ast_unrolled)
48+
49+
50+
def test_nested_kernels():
51+
@qasm2.main
52+
def nested(q: qasm2.QReg, c: qasm2.CReg):
53+
qasm2.h(q[0])
54+
55+
qasm2.measure(q, c)
56+
if c[0] == 1:
57+
qasm2.x(q[0])
58+
qasm2.x(q[1])
59+
60+
return q
61+
62+
@qasm2.main
63+
def main():
64+
q = qasm2.qreg(2)
65+
c = qasm2.creg(2)
66+
67+
nested(q, c)
68+
69+
return c
70+
71+
target = QASM2()
72+
ast = target.emit(main)
73+
74+
qasm2.parse.pprint(ast)

0 commit comments

Comments
 (0)