Skip to content

Commit

Permalink
Fixing #56
Browse files Browse the repository at this point in the history
  • Loading branch information
cacharle committed Aug 9, 2023
1 parent 8d72dfc commit e861f5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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

0 comments on commit e861f5e

Please sign in to comment.