diff --git a/test/unit_tests/autoqasm/test_types.py b/test/unit_tests/autoqasm/test_types.py index 839701c..37550a1 100644 --- a/test/unit_tests/autoqasm/test_types.py +++ b/test/unit_tests/autoqasm/test_types.py @@ -199,6 +199,8 @@ def declare_array(): b[2] = 14; b = a;""" + print(declare_array.build().to_ir()) + assert declare_array.build().to_ir() == expected @@ -726,7 +728,7 @@ def main(): main.build() -def test_ArrayVar_does_not_need_dimensions_argument(): +def test_array_does_not_accept_dimensions_argument(): @aq.main def declare_array(): aq.ArrayVar([1, 2, 3], base_type=aq.IntVar, dimensions=[3]) @@ -735,10 +737,21 @@ def declare_array(): declare_array.build() -def test_ArrayVar_requires_init_expression(): +def test_array_requires_init_expression(): @aq.main def declare_array(): aq.ArrayVar() - with pytest.raises(aq.errors.InvalidArrayDeclaration): + with pytest.raises(TypeError): declare_array.build() + + +def test_array_supports_multidimensional_arrays(): + @aq.main + def declare_array(): + aq.ArrayVar([[1, 2], [3, 4]]) + + expected = """OPENQASM 3.0; +array[int[32], 2, 2] a = {{1, 2}, {3, 4}};""" + + declare_array.build().to_ir() == expected