mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-28 06:56:57 +08:00
Temporary work on carriage returns.
This commit is contained in:
@@ -104,3 +104,17 @@ def test_end_newlines():
|
||||
test('def a():\n pass', (2, 5))
|
||||
|
||||
test('def a(', (1, 6))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(('code', 'types'), [
|
||||
('\r', ['error_leaf', 'endmarker']),
|
||||
('\n\r', ['error_leaf', 'endmarker'])
|
||||
])
|
||||
def test_carriage_return_at_end(code, types):
|
||||
"""
|
||||
By adding an artificial newline this creates weird side effects for
|
||||
\r at the end of files that would normally be error leafs.
|
||||
"""
|
||||
tree = parse(code)
|
||||
assert tree.get_code() == code
|
||||
assert [c.type for c in tree.children] == types
|
||||
|
||||
@@ -15,6 +15,7 @@ import parso
|
||||
('\\', ['\\']),
|
||||
('\\\n', ['\\\n']),
|
||||
('\\\r\n', ['\\\r\n']),
|
||||
('\t\t\n\t', ['\t\t', '\n', '\t']),
|
||||
])
|
||||
def test_simple_prefix_splitting(string, tokens):
|
||||
tree = parso.parse(string)
|
||||
@@ -42,6 +43,7 @@ def test_simple_prefix_splitting(string, tokens):
|
||||
('\r\n', ['newline']),
|
||||
('\f', ['formfeed']),
|
||||
('\\\n', ['backslash']),
|
||||
('\r', ['newline']),
|
||||
])
|
||||
def test_prefix_splitting_types(string, types):
|
||||
tree = parso.parse(string)
|
||||
|
||||
Reference in New Issue
Block a user