Skip to content
Open
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
33 changes: 33 additions & 0 deletions tests/test_reformat.py
Original file line number Diff line number Diff line change
@@ -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
Loading