From 1c42c17117e43a7658b7d8a3d1b95925c92dc329 Mon Sep 17 00:00:00 2001 From: Yash-10 Date: Fri, 31 May 2024 08:20:11 +0530 Subject: [PATCH] Add test for multidimensional array support remove print --- test/unit_tests/autoqasm/test_types.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/test/unit_tests/autoqasm/test_types.py b/test/unit_tests/autoqasm/test_types.py index 839701c..0e6ad74 100644 --- a/test/unit_tests/autoqasm/test_types.py +++ b/test/unit_tests/autoqasm/test_types.py @@ -726,7 +726,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 +735,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