@@ -1184,9 +1184,9 @@ def h_nested(target):
11841184
11851185def test_ir_empty_instructions_result_types ():
11861186 circ = Circuit ()
1187- assert circ . to_ir () == jaqcd . Program (
1188- instructions = [], results = [], basis_rotation_instructions = []
1189- )
1187+ with pytest . warns ( UserWarning , match = "JAQCD" ):
1188+ ir = circ . to_ir ( IRType . JAQCD )
1189+ assert ir == jaqcd . Program ( instructions = [], results = [], basis_rotation_instructions = [] )
11901190
11911191
11921192def test_ir_non_empty_instructions_result_types ():
@@ -1196,7 +1196,9 @@ def test_ir_non_empty_instructions_result_types():
11961196 results = [jaqcd .Probability (targets = [0 , 1 ])],
11971197 basis_rotation_instructions = [],
11981198 )
1199- assert circ .to_ir () == expected
1199+ with pytest .warns (UserWarning , match = "JAQCD" ):
1200+ ir = circ .to_ir (IRType .JAQCD )
1201+ assert ir == expected
12001202
12011203
12021204def test_ir_non_empty_instructions_result_types_basis_rotation_instructions ():
@@ -1206,7 +1208,16 @@ def test_ir_non_empty_instructions_result_types_basis_rotation_instructions():
12061208 results = [jaqcd .Sample (observable = ["x" ], targets = [0 ])],
12071209 basis_rotation_instructions = [jaqcd .H (target = 0 )],
12081210 )
1209- assert circ .to_ir () == expected
1211+ with pytest .warns (UserWarning , match = "JAQCD" ):
1212+ ir = circ .to_ir (IRType .JAQCD )
1213+ assert ir == expected
1214+
1215+
1216+ def test_to_ir_default_is_openqasm ():
1217+ """Calling Circuit.to_ir() with no ir_type argument should return an
1218+ OpenQASM program (after the JAQCD-deprecation default flip)."""
1219+ circ = Circuit ().h (0 ).cnot (0 , 1 )
1220+ assert isinstance (circ .to_ir (), OpenQasmProgram )
12101221
12111222
12121223@pytest .mark .parametrize (
@@ -3815,5 +3826,8 @@ def test_barrier_openqasm_export_all_qubits():
38153826
38163827def test_barrier_jaqcd_export_fails ():
38173828 circ = Circuit ().h (0 ).barrier ([0 , 1 ])
3818- with pytest .raises (NotImplementedError , match = "Barrier is not supported in JAQCD" ):
3829+ with (
3830+ pytest .warns (UserWarning , match = "JAQCD" ),
3831+ pytest .raises (NotImplementedError , match = "Barrier is not supported in JAQCD" ),
3832+ ):
38193833 circ .to_ir (IRType .JAQCD )
0 commit comments