support escaped arrays and functions

This commit is contained in:
2024-09-21 00:50:39 +03:00
parent b3208ce263
commit 59162ba45f
2 changed files with 25 additions and 10 deletions

View File

@ -68,7 +68,7 @@ def test_parse_array_comment() -> None:
])]
def test_parse_array_quotes() -> None:
def test_parse_array_escaped() -> None:
"""
must correctly process quoted brackets
"""
@ -81,6 +81,9 @@ def test_parse_array_quotes() -> None:
parser = PkgbuildParser(StringIO("""var=(first ')' second)"""))
assert list(parser.parse()) == [PkgbuildPatch("var", ["first", ")", "second"])]
parser = PkgbuildParser(StringIO("""var=(first \\) second)"""))
assert list(parser.parse()) == [PkgbuildPatch("var", ["first", ")", "second"])]
def test_parse_array_exception() -> None:
"""
@ -123,7 +126,7 @@ def test_parse_function_inner_shell() -> None:
assert list(parser.parse()) == [PkgbuildPatch("var()", "{ { echo hello world } }")]
def test_parse_function_quotes() -> None:
def test_parse_function_escaped() -> None:
"""
must parse function with bracket in quotes
"""
@ -142,6 +145,9 @@ def test_parse_function_quotes() -> None:
parser = PkgbuildParser(StringIO("""var ( ) { echo hello world '}' } """))
assert list(parser.parse()) == [PkgbuildPatch("var()", """{ echo hello world '}' }""")]
parser = PkgbuildParser(StringIO("""var ( ) { echo hello world \\} } """))
assert list(parser.parse()) == [PkgbuildPatch("var()", """{ echo hello world \\} }""")]
def test_parse_function_exception() -> None:
"""