From b0e52e000bca3239cdd7b52988753c0da7e8f81e Mon Sep 17 00:00:00 2001 From: Jakub Pavlik Date: Sun, 23 Nov 2025 00:18:57 +0100 Subject: [PATCH] some tests for ly.reformat --- tests/test_reformat.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_reformat.py diff --git a/tests/test_reformat.py b/tests/test_reformat.py new file mode 100644 index 0000000..156cb81 --- /dev/null +++ b/tests/test_reformat.py @@ -0,0 +1,33 @@ +import pytest + +import ly.document +import ly.indent +import ly.reformat + + +def _expect_unchanged(input): + return (input, input) + + +@pytest.mark.parametrize('given,expected', [ + ('', ''), + (' ', ''), + (" \\version \"2.24.0\" ", "\\version \"2.24.0\""), + + ("\\relative { c''4 c \n c c }", + "\\relative {\n c''4 c\n c c\n}"), + + _expect_unchanged("\\version \"2.24.0\" \\score { \\new Staff \\relative { c''4 c c c } }"), + ("\\score { \n \\new Staff \\relative { c''4 c c c } }", + "\\score {\n \\new Staff \\relative { c''4 c c c }\n}"), + ("\\score { \\new Staff \\relative { c''4 c \n c c } }", + "\\score {\n \\new Staff \\relative {\n c''4 c\n c c\n }\n}"), +]) +def test_reformat(given, expected): + indenter = ly.indent.Indenter() + + doc = ly.document.Document(given) + cursor = ly.document.Cursor(doc) + ly.reformat.reformat(cursor, indenter) + + assert cursor.text() == expected