Skip to content

Commit

Permalink
remove print_arguments (only used for testing now)
Browse files Browse the repository at this point in the history
  • Loading branch information
Felienne committed Sep 27, 2023
1 parent 41cd98f commit 2af9514
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
42 changes: 0 additions & 42 deletions hedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,48 +1077,6 @@ def all_commands(input_string, level, lang='en'):
return AllCommands(level).transform(program_root)


class AllPrintArguments(Transformer):
def __init__(self, level):
self.level = level

def __default__(self, args, children, meta):
leaves = flatten_list_of_lists_to_list(children)

if args == 'print':
return children
else:
return leaves # 'pop up' the children

def program(self, args):
return flatten_list_of_lists_to_list(args)

# somehow tokens are not picked up by the default rule so they need their own rule
def INT(self, args):
return []

def NAME(self, args):
return []

def NUMBER(self, args):
return []

def POSITIVE_NUMBER(self, args):
return []

def NEGATIVE_NUMBER(self, args):
return []

def text(self, args):
return ''.join(args)

# TODO in this PR: should be removed everywhere
# not just in achievements
def all_print_arguments(input_string, level, lang='en'):
input_string = process_input_string(input_string, level, lang)
program_root = parse_input(input_string, level, lang)

return AllPrintArguments(level).transform(program_root)


@v_args(meta=True)
class IsValid(Filter):
Expand Down
7 changes: 2 additions & 5 deletions tests/test_level/test_level_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_print(self):
expected=expected,
output=output,
expected_commands=expected_commands

)
self.assertEqual([output], hedy.all_print_arguments(code, self.level))

def test_print_no_space(self):
code = "printHallo welkom bij Hedy!"
Expand All @@ -53,7 +53,7 @@ def test_print_no_space(self):
output=output,
expected_commands=expected_commands
)
self.assertEqual([output], hedy.all_print_arguments(code, self.level))


def test_print_line_with_spaces_works(self):
code = "print hallo\n \nprint hallo"
Expand Down Expand Up @@ -83,7 +83,6 @@ def test_print_multiple_lines(self):
Mooi hoor""")

self.single_level_tester(code=code, expected=expected, output=output)
self.assertEqual(['Hallo welkom bij Hedy', 'Mooi hoor'], hedy.all_print_arguments(code, self.level))

def test_print_single_quoted_text(self):
code = "print 'Welcome to OceanView!'"
Expand Down Expand Up @@ -519,8 +518,6 @@ def test_print_comment(self):
expected_commands=[Command.print]
)

self.assertEqual(['Hallo welkom bij Hedy! '], hedy.all_print_arguments(code, self.level))

#
# combined commands tests
#
Expand Down

0 comments on commit 2af9514

Please sign in to comment.