From dc0a30f8af50148ad274148fcded00e5d23039b9 Mon Sep 17 00:00:00 2001 From: "Davide Gessa (dakk)" Date: Wed, 1 Nov 2023 17:16:27 +0100 Subject: [PATCH] fix vscode testing --- .vscode/settings.json | 4 ++-- test/__init__.py | 5 +++++ test/test_qlassf_builtin.py | 16 ++++++++++++++-- test/test_qlassf_for_loop.py | 11 ++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3a7ba1cf..f6441a68 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,9 +2,9 @@ "python.testing.unittestArgs": [ "-v", "-s", - "./test", + "./", "-p", - "*test.py" + "*.py" ], "python.testing.pytestEnabled": false, "python.testing.unittestEnabled": true diff --git a/test/__init__.py b/test/__init__.py index 34db42e8..639513f5 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -11,3 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +try: + import utils # needed by vscode +except: + pass diff --git a/test/test_qlassf_builtin.py b/test/test_qlassf_builtin.py index adbc9a2a..525ec529 100644 --- a/test/test_qlassf_builtin.py +++ b/test/test_qlassf_builtin.py @@ -80,9 +80,9 @@ def test_max_const(self): qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) compute_and_compare_results(self, qf) - # TODO: fixed by cast + # TODO: fix cast # def test_max_const2(self): - # f = "def test(a: Qint4) -> Qint2:\n\treturn max(a,3)" + # f = "def test(a: Qint4) -> Qint4:\n\treturn max(a,3)" # qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) # compute_and_compare_results(self, qf) @@ -95,3 +95,15 @@ def test_max_tuple_const(self): f = "def test(a: Qint2, b: Qint2) -> Qint2:\n\treturn max((a, b))" qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) compute_and_compare_results(self, qf) + + # TODO: + # def test_len_of_range(self): + # f = "def test() -> Qint4:\n\treturn len(range(4))" + # qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) + # compute_and_compare_results(self, qf) + + # TODO: + # def test_range_of_len(self): + # f = "def test(a: Qlist[bool, 3]) -> Qint4:\n\treturn range(len(a))" + # qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) + # compute_and_compare_results(self, qf) diff --git a/test/test_qlassf_for_loop.py b/test/test_qlassf_for_loop.py index cc022986..0b319ca0 100644 --- a/test/test_qlassf_for_loop.py +++ b/test/test_qlassf_for_loop.py @@ -63,10 +63,7 @@ def test_for_cond(self): qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) compute_and_compare_results(self, qf) - -# TODO: a test to do -# def hash(k: Qint4) -> bool: -# z = 1 -# for i in range(3): -# z += i -# return z == 3 + def test_for_sum(self): + f = "def hash(k: Qint4) -> bool:\n\tz = 1\n\tfor i in range(3):\n\t\tz += i\n\treturn z == 3" + qf = qlassf(f, to_compile=COMPILATION_ENABLED, compiler=self.compiler) + compute_and_compare_results(self, qf)