From 7cfe6312f72f4305e6cd32d89e9acf7d5707ab9f Mon Sep 17 00:00:00 2001 From: boryanagoncharenko Date: Fri, 26 Jul 2024 13:47:36 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Automatically=20update=20generat?= =?UTF-8?q?ed=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grammars/keywords-hr.lark | 4 +- tests/test_level/test_level_14.py | 92 +++++++++++++------------------ 2 files changed, 39 insertions(+), 57 deletions(-) diff --git a/grammars/keywords-hr.lark b/grammars/keywords-hr.lark index 632fdb5d3ad..a2113a710af 100644 --- a/grammars/keywords-hr.lark +++ b/grammars/keywords-hr.lark @@ -26,9 +26,9 @@ _IS: _SPACE ("is" | "is") _SPACE _STANDALONE_IS: ("is" | "is") _SLEEP: ("sleep" | "sleep") _SPACE? _ADD_LIST: ("add" | "add") _SPACE -_TO_LIST: _SPACE ("to" | "to") _SPACE +_TO_LIST: _SPACE? ("to" | "to") _SPACE _REMOVE: ("remove" | "remove") _SPACE -_FROM: _SPACE ("from" | "from") _SPACE +_FROM: _SPACE? ("from" | "from") _SPACE _AT: _SPACE ("at" | "at") _SPACE random: ("random" | "random") _SPACE? _IN: _SPACE ("in" | "in") _SPACE diff --git a/tests/test_level/test_level_14.py b/tests/test_level/test_level_14.py index e9fde7291e5..8e7e2f194f9 100644 --- a/tests/test_level/test_level_14.py +++ b/tests/test_level/test_level_14.py @@ -128,6 +128,25 @@ def test_equality_of_lists(self, comparison): expected=expected, max_level=15) + @parameterized.expand(HedyTester.equality_comparison_commands) + def test_equality_with_lists(self, comparison): + code = textwrap.dedent(f"""\ + a = 1, 2 + b = 1, 2 + if a {comparison} b + sleep""") + + expected = textwrap.dedent(f"""\ + a = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) + b = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) + if a.data == b.data: + time.sleep(1)""") + + self.multi_level_tester( + code=code, + expected=expected, + max_level=15) + # # inequality tests / not equals tests # @@ -263,6 +282,24 @@ def test_inequality_of_lists(self): expected=expected, max_level=15) + def test_inequality_with_lists(self): + code = textwrap.dedent("""\ + a = 1, 2 + b = 1, 2 + if a != b + sleep""") + + expected = textwrap.dedent("""\ + a = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) + b = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) + if a.data!=b.data: + time.sleep(1)""") + + self.multi_level_tester( + code=code, + expected=expected, + max_level=15) + @parameterized.expand([ ('"text"', '1'), # double-quoted text and number ("'text'", '1'), # single-quoted text and number @@ -347,7 +384,6 @@ def test_comparison_with_int(self, comparison): max_level=16, expected=expected) - @parameterized.expand([ ('>', 'incorrect'), ('>=', 'correct'), @@ -464,60 +500,6 @@ def test_comparison_with_list_gives_type_error(self, comparison): exception=hedy.exceptions.InvalidArgumentTypeException ) - def test_if_with_double_equals(self): - code = textwrap.dedent("""\ - naam = 'Hedy' - if naam == 'Hedy' - print 'koekoek'""") - - expected = textwrap.dedent("""\ - naam = Value('Hedy') - if naam.data == 'Hedy': - print(f'''koekoek''')""") - - self.multi_level_tester( - code=code, - expected=expected, - max_level=16, - skip_faulty=False) - - @parameterized.expand(HedyTester.equality_comparison_commands) - def test_equality_with_lists(self, comparison): - code = textwrap.dedent(f"""\ - a = 1, 2 - b = 1, 2 - if a {comparison} b - sleep""") - - expected = textwrap.dedent(f"""\ - a = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) - b = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) - if a.data == b.data: - time.sleep(1)""") - - self.multi_level_tester( - code=code, - expected=expected, - max_level=15) - - def test_inequality_with_lists(self): - code = textwrap.dedent("""\ - a = 1, 2 - b = 1, 2 - if a != b - sleep""") - - expected = textwrap.dedent("""\ - a = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) - b = Value([Value(1, num_sys='Latin'), Value(2, num_sys='Latin')]) - if a.data!=b.data: - time.sleep(1)""") - - self.multi_level_tester( - code=code, - expected=expected, - max_level=15) - @parameterized.expand(HedyTester.comparison_commands) def test_comparison_with_boolean(self, comparison): code = textwrap.dedent(f"""\