Skip to content

Commit 56f2493

Browse files
ryanhill1claude
andcommitted
Add tests for multiple classical registers and multiple box statements
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b13d4e7 commit 56f2493

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/qasm3/test_box.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,52 @@ def test_box_measurement_with_enclosing_block_scope():
282282
"""
283283
result = loads(qasm_str)
284284
result.validate()
285+
286+
287+
def test_box_measurement_with_multiple_classical_registers():
288+
"""Measurement inside a box should have access to multiple classical
289+
registers declared in the enclosing (global) scope."""
290+
qasm_str = """
291+
OPENQASM 3.0;
292+
include "stdgates.inc";
293+
qubit[4] q;
294+
bit[3] c0;
295+
bit[2] c1;
296+
297+
box {
298+
c0[0] = measure q[0];
299+
c0[2] = measure q[2];
300+
c1[1] = measure q[3];
301+
}
302+
"""
303+
result = loads(qasm_str)
304+
result.validate()
305+
306+
307+
def test_multiple_box_statements():
308+
"""Multiple box statements in the same program should each have access
309+
to classical registers from the enclosing scope."""
310+
qasm_str = """
311+
OPENQASM 3.0;
312+
include "stdgates.inc";
313+
qubit[4] q;
314+
bit[4] c;
315+
316+
box [50ns] {
317+
h q[0];
318+
c[0] = measure q[0];
319+
}
320+
321+
box [100ns] {
322+
cx q[1], q[2];
323+
c[1] = measure q[1];
324+
c[2] = measure q[2];
325+
}
326+
327+
box {
328+
h q[3];
329+
c[3] = measure q[3];
330+
}
331+
"""
332+
result = loads(qasm_str)
333+
result.validate()

0 commit comments

Comments
 (0)