diff --git a/c_formatter_42/formatters/line_breaker.py b/c_formatter_42/formatters/line_breaker.py index 4a74411..f29fdac 100644 --- a/c_formatter_42/formatters/line_breaker.py +++ b/c_formatter_42/formatters/line_breaker.py @@ -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 @@ -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") diff --git a/requirements-dev.txt b/requirements-dev.txt index 0e3a74b..91c9c08 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ pytest pytest-cov +pytest-timeout six pytest-clarity mypy diff --git a/tests/test_run.py b/tests/test_run.py index e3381f5..dbae673 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -1,14 +1,14 @@ -# ############################################################################ # +# **************************************************************************** # # # # ::: :::::::: # # test_run.py :+: :+: :+: # # +:+ +:+ +:+ # -# By: charles +#+ +:+ +#+ # +# By: yaassila +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # 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 @@ -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)