Skip to content

Commit

Permalink
Add test for multidimensional array support
Browse files Browse the repository at this point in the history
remove print
  • Loading branch information
Yash-10 committed May 31, 2024
1 parent d823ac9 commit 1c42c17
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/unit_tests/autoqasm/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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

0 comments on commit 1c42c17

Please sign in to comment.