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

Fixing #56 #57

Merged
merged 1 commit into from
Aug 9, 2023
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
2 changes: 1 addition & 1 deletion c_formatter_42/formatters/hoist.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def hoist(content: str) -> str:
r"(?P<value>.+);$".format(t=helper.REGEX_TYPE, d=helper.REGEX_DECL_NAME),
line,
)
if m is not None:
if m is not None and re.match(r".*\[.*\].*", m.group("name")) is None:
lines.append(f"\t{m.group('type')}\t{m.group('name')};")
lines.append(
"{}{} = {};".format(
Expand Down
16 changes: 16 additions & 0 deletions tests/formatters/test_hoist.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ def test_hoist_empty_function():
assert output == hoist(input)


def test_hoist_array_initialization():
input = """
void foo(void)
{
\tint xs[4] = {1, 2, 3, 4};
}
"""
output = """
void foo(void)
{
\tint xs[4] = {1, 2, 3, 4};
}
"""
assert output == hoist(input)


@pytest.mark.skip()
def test_hoist_array():
pass
Expand Down
Loading