From f6bea1645cdc8adc8ce32537a64f96750c264ad8 Mon Sep 17 00:00:00 2001 From: Pradnya Khalate Date: Fri, 22 Nov 2024 16:23:15 -0800 Subject: [PATCH] * More tests Signed-off-by: Pradnya Khalate --- python/tests/backends/test_braket.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/python/tests/backends/test_braket.py b/python/tests/backends/test_braket.py index d730358c01..bfe6ce7835 100644 --- a/python/tests/backends/test_braket.py +++ b/python/tests/backends/test_braket.py @@ -290,6 +290,36 @@ def kernel(qubit_count: int): assert "1111" in counts +def test_qvector_slicing(): + + @cudaq.kernel + def kernel(): + q = cudaq.qvector(4) + x(q.front(2)) + mz(q) + + ## error: 'quake.subveq' op unable to translate op to OpenQASM 2.0 + with pytest.raises(RuntimeError) as e: + cudaq.sample(kernel, shots_count=100).dump() + assert "Could not successfully translate to qasm2" in repr(e) + + +def test_mid_circuit_measurement(): + + @cudaq.kernel + def simple(): + q = cudaq.qvector(2) + h(q[0]) + if mz(q[0]): + x(q[1]) + mz(q) + + ## error: 'cf.cond_br' op unable to translate op to OpenQASM 2.0 + with pytest.raises(RuntimeError) as e: + cudaq.sample(simple, shots_count=100).dump() + assert "Could not successfully translate to qasm2" in repr(e) + + @pytest.mark.parametrize("device_arn", [ "arn:aws:braket:::device/quantum-simulator/amazon/dm1", "arn:aws:braket:::device/quantum-simulator/amazon/tn1"