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

Fix #58 #64

Merged
merged 5 commits into from
Aug 31, 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
4 changes: 2 additions & 2 deletions c_formatter_42/formatters/line_breaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def additional_indent_level(s: str, nest_indent_level: int = 0) -> int:
def additional_nest_indent_level(line: str) -> int:
# An exceptional rule for variable assignment
# https://github.com/42School/norminette/blob/921b5e22d991591f385e1920f7e7ee5dcf71f3d5/norminette/rules/check_assignation_indent.py#L59
align_pattern = r"^\s*({decl})((\.|->){decl})*\s+=\s+[^;]*?;$"
align_pattern = r"^\s*({decl})((\.|->){decl})*\s+=\s+[^;]*?;"
align_pattern = align_pattern.format(decl=helper.REGEX_DECL_NAME)
return 1 if re.match(align_pattern, line) is not None else 0

Expand All @@ -94,7 +94,7 @@ def line_length(line: str) -> int:
def indent_level(line: str) -> int:
# An exceptional rule for function declaration
# https://github.com/42School/norminette/blob/921b5e22d991591f385e1920f7e7ee5dcf71f3d5/norminette/rules/check_assignation_indent.py#L61
align_pattern = r"^(static\s+)?{type}\s+{name}\((.|\s)*?\);"
align_pattern = r"^(static\s+)?{type}\s+{name}\([^)]*?\);"
align_pattern = align_pattern.format(type=helper.REGEX_TYPE, name=helper.REGEX_NAME)
if re.match(align_pattern, line):
last_tab_index = line.rfind("\t")
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pytest
pytest-cov
pytest-timeout
six
pytest-clarity
mypy
Expand Down
26 changes: 22 additions & 4 deletions tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ############################################################################ #
# **************************************************************************** #
# #
# ::: :::::::: #
# test_run.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: charles <[email protected]> +#+ +:+ +#+ #
# By: yaassila <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/02/08 19:56:48 by charles #+# #+# #
# Updated: 2021/02/11 20:27:07 by charles ### ########.fr #
# Updated: 2023/08/31 14:00:00 by yaassila ### ########.fr #
# #
# ############################################################################ #
# **************************************************************************** #

import pytest

Expand Down Expand Up @@ -82,3 +82,21 @@ def test_basic():
}
"""
assert output == run_all(input)


@pytest.mark.timeout(15)
def test_function_call_in_comment():
input = """
#include "libft.h"

/*
The bzero() function erases the data in the n bytes of the memory starting at the location pointed to by s, by writing zeros (bytes containing '\\0') to that area.

The explicit_bzero() function performs the same task as bzero(). It differs from bzero() in that it guarantees that compiler optimizations will not remove the erase operation if the compiler deduces that the operation is "un-necessary".
*/
void bzero(void *s, size_t n)
{
unsigned char *ptr_s;
}
"""
run_all(input)
Loading