Skip to content

Commit

Permalink
🤖 Automatically update generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
boryanagoncharenko committed Aug 8, 2024
1 parent b354c35 commit 7cfe631
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 57 deletions.
4 changes: 2 additions & 2 deletions grammars/keywords-hr.lark
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 37 additions & 55 deletions tests/test_level/test_level_14.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -347,7 +384,6 @@ def test_comparison_with_int(self, comparison):
max_level=16,
expected=expected)


@parameterized.expand([
('>', 'incorrect'),
('>=', 'correct'),
Expand Down Expand Up @@ -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"""\
Expand Down

0 comments on commit 7cfe631

Please sign in to comment.