mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
Initial sketch of automated indent tests
This commit is contained in:
parent
eefa5662e6
commit
67f2c7149c
14 changed files with 257 additions and 0 deletions
11
lua/tests/indent/python/aligned_indent.py
Normal file
11
lua/tests/indent/python/aligned_indent.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
def aligned_indent(arg1,
|
||||
arg2):
|
||||
pass
|
||||
|
||||
aligned_indent(1,
|
||||
2)
|
||||
|
||||
|
||||
aligned_indent(1,
|
||||
2
|
||||
)
|
||||
14
lua/tests/indent/python/basic_blocks.py
Normal file
14
lua/tests/indent/python/basic_blocks.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from os import (
|
||||
path,
|
||||
name as OsName
|
||||
)
|
||||
|
||||
def foo(x):
|
||||
pass
|
||||
|
||||
class Foo:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def foo(self):
|
||||
pass
|
||||
23
lua/tests/indent/python/basic_collections.py
Normal file
23
lua/tests/indent/python/basic_collections.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# list
|
||||
a = [
|
||||
1, 2,
|
||||
3
|
||||
]
|
||||
|
||||
# set
|
||||
b = {
|
||||
3,
|
||||
4,
|
||||
}
|
||||
|
||||
# dict
|
||||
c = {
|
||||
'a': 'b',
|
||||
'c': 1,
|
||||
}
|
||||
|
||||
# tuple
|
||||
d = (
|
||||
1,
|
||||
2,
|
||||
)
|
||||
27
lua/tests/indent/python/branches.py
Normal file
27
lua/tests/indent/python/branches.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
a = [
|
||||
1, 2, 3]
|
||||
|
||||
b = [
|
||||
x + 1
|
||||
for x in range(3)]
|
||||
|
||||
c = [[[
|
||||
1
|
||||
]]]
|
||||
|
||||
d = [[[
|
||||
4]]]
|
||||
|
||||
e = [[
|
||||
1], 2, 3]
|
||||
|
||||
def foo(x, y):
|
||||
pass
|
||||
|
||||
foo(
|
||||
a,
|
||||
b)
|
||||
|
||||
if (a and
|
||||
b):
|
||||
pass
|
||||
25
lua/tests/indent/python/comprehensions.py
Normal file
25
lua/tests/indent/python/comprehensions.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# list
|
||||
a = [
|
||||
x + 1 for x in range(3)
|
||||
]
|
||||
|
||||
# dict
|
||||
b = {
|
||||
x: x + 1 for x in range(3)
|
||||
}
|
||||
|
||||
# generator
|
||||
c = (
|
||||
x * x for x in range(3)
|
||||
)
|
||||
|
||||
# set
|
||||
d = {
|
||||
x + x for x in range(3)
|
||||
}
|
||||
|
||||
# other styles
|
||||
e = [
|
||||
x + 1 for x
|
||||
in range(3)
|
||||
]
|
||||
24
lua/tests/indent/python/control_flow.py
Normal file
24
lua/tests/indent/python/control_flow.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
a, b, c, = 1, 2, 3
|
||||
|
||||
if a == a:
|
||||
x = 1
|
||||
elif b:
|
||||
x = 2
|
||||
else:
|
||||
x = 3
|
||||
|
||||
while False:
|
||||
pass
|
||||
|
||||
for _ in range(3):
|
||||
pass
|
||||
|
||||
with open('/tmp/f', 'w') as f:
|
||||
pass
|
||||
|
||||
try:
|
||||
pass
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
pass
|
||||
6
lua/tests/indent/python/hanging_indent.py
Normal file
6
lua/tests/indent/python/hanging_indent.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
def hanging_indent(
|
||||
arg1, arg2):
|
||||
pass
|
||||
|
||||
hanging_indent(
|
||||
1, 2)
|
||||
8
lua/tests/indent/python/join_lines.py
Normal file
8
lua/tests/indent/python/join_lines.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a = 2 \
|
||||
+ 2
|
||||
|
||||
b = 'hello' \
|
||||
'world'
|
||||
|
||||
c = lambda x: \
|
||||
x + 3
|
||||
41
lua/tests/indent/python/nested_collections.py
Normal file
41
lua/tests/indent/python/nested_collections.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
a = [
|
||||
1,
|
||||
[
|
||||
2,
|
||||
[
|
||||
3
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
b = [
|
||||
1, [[
|
||||
3
|
||||
],
|
||||
]
|
||||
]
|
||||
|
||||
c = [[[
|
||||
3
|
||||
]]]
|
||||
|
||||
d = {
|
||||
'a': [
|
||||
2, 3
|
||||
],
|
||||
'c': (
|
||||
[1, 2, 3],
|
||||
[
|
||||
2,
|
||||
4
|
||||
], {
|
||||
6,
|
||||
8
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
e = (1, 2,
|
||||
3, 4,
|
||||
5, 6
|
||||
)
|
||||
17
lua/tests/indent/python/strings.py
Normal file
17
lua/tests/indent/python/strings.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
a = """
|
||||
String A
|
||||
"""
|
||||
|
||||
b = """
|
||||
String B
|
||||
"""
|
||||
|
||||
c = """
|
||||
String C
|
||||
"""
|
||||
|
||||
d = """
|
||||
String D
|
||||
String D
|
||||
String D
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue