Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix broken tests #4882

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ logs.txt
.local
node_modules

# Ignore things that start with underscores
# Ignore things that start with underscores (except __init__.py)
_*
!__init__.py
# Ignore pickled versions of YAML files
*.yaml.pickle
dev_database.json
Expand Down
2 changes: 1 addition & 1 deletion hedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,6 @@ def create_lookup_table(abstract_syntax_tree, level, lang, input_string):


def create_AST(input_string, level, lang="en"):
input_string = process_input_string(input_string, level, lang)
program_root = parse_input(input_string, level, lang)

try:
Expand Down Expand Up @@ -3377,6 +3376,7 @@ def create_AST(input_string, level, lang="en"):

def transpile_inner(input_string, level, lang="en", populate_source_map=False, is_debug=False):
check_program_size_is_valid(input_string)
input_string = process_input_string(input_string, level, lang)

level = int(level)
if level > HEDY_MAX_LEVEL:
Expand Down
Empty file added tests/__init__.py
Empty file.
49 changes: 24 additions & 25 deletions tests/test_level/test_level_05.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,31 +186,30 @@ def test_if_equality_unquoted_rhs_with_space_print_gives_error(self):
max_level=7
)

# Disabled in 4838
# def test_if_equality_unquoted_rhs_with_space_and_following_command_print_gives_error(self):
# code = textwrap.dedent("""\
# naam is James
# if naam is James Bond print 'shaken'
# print naam
# prind skipping""")
#
# expected = textwrap.dedent("""\
# naam = 'James'
# pass
# print(f'{naam}')
# pass""")
#
# skipped_mappings = [
# SkippedMapping(SourceRange(2, 1, 2, 59), hedy.exceptions.UnquotedEqualityCheckException),
# SkippedMapping(SourceRange(4, 1, 4, 15), hedy.exceptions.InvalidCommandException)
# ]
#
# self.multi_level_tester(
# code=code,
# expected=expected,
# skipped_mappings=skipped_mappings,
# max_level=7
# )
def test_if_equality_unquoted_rhs_with_space_and_following_command_print_gives_error(self):
code = textwrap.dedent("""\
naam is James
if naam is James Bond print 'shaken'
print naam
prind skipping""")

expected = textwrap.dedent("""\
naam = 'James'
pass
print(f'{naam}')
pass""")

skipped_mappings = [
SkippedMapping(SourceRange(2, 1, 2, 58), hedy.exceptions.UnquotedEqualityCheckException),
SkippedMapping(SourceRange(4, 1, 4, 15), hedy.exceptions.InvalidCommandException)
]

self.multi_level_tester(
code=code,
expected=expected,
skipped_mappings=skipped_mappings,
max_level=7
)

def test_if_equality_unquoted_rhs_with_space_assign_gives_error(self):
code = textwrap.dedent("""\
Expand Down
37 changes: 18 additions & 19 deletions tests/test_level/test_level_07.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,24 @@ def test_repeat_with_missing_print_gives_error(self):
exception=hedy.exceptions.IncompleteRepeatException
)

# Disabled in 4838
# def test_repeat_with_missing_times_gives_error_skip(self):
# code = textwrap.dedent("""\
# x is 3
# repeat 3 print 'x'""")
#
# expected = textwrap.dedent("""\
# x = '3'
# pass""")
#
# skipped_mappings = [
# SkippedMapping(SourceRange(2, 1, 2, 17), hedy.exceptions.IncompleteRepeatException),
# ]
#
# self.single_level_tester(
# code=code,
# expected=expected,
# skipped_mappings=skipped_mappings,
# )
def test_repeat_with_missing_times_gives_error_skip(self):
code = textwrap.dedent("""\
x is 3
repeat 3 print 'x'""")

expected = textwrap.dedent("""\
x = '3'
pass""")

skipped_mappings = [
SkippedMapping(SourceRange(2, 1, 2, 19), hedy.exceptions.IncompleteRepeatException),
]

self.single_level_tester(
code=code,
expected=expected,
skipped_mappings=skipped_mappings,
)

def test_repeat_with_missing_print_gives_lonely_text_exc(self):
code = textwrap.dedent("""\
Expand Down
Loading