diff options
| author | Jędrzej Boczar <yendreij@gmail.com> | 2021-03-13 22:46:45 +0100 |
|---|---|---|
| committer | Kiyan <yazdani.kiyan@protonmail.com> | 2021-04-23 21:21:38 +0200 |
| commit | 67f2c7149c0de39248f1bdeba1a4303b156c3199 (patch) | |
| tree | 1365bbaddf0570e2ab3d051bd3b4e7e2c876e2a6 /lua/tests | |
| parent | replace @class with @type (diff) | |
| download | nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar.gz nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar.bz2 nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar.lz nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar.xz nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.tar.zst nvim-treesitter-67f2c7149c0de39248f1bdeba1a4303b156c3199.zip | |
Initial sketch of automated indent tests
Diffstat (limited to 'lua/tests')
| -rw-r--r-- | lua/tests/indent/python/aligned_indent.py | 11 | ||||
| -rw-r--r-- | lua/tests/indent/python/basic_blocks.py | 14 | ||||
| -rw-r--r-- | lua/tests/indent/python/basic_collections.py | 23 | ||||
| -rw-r--r-- | lua/tests/indent/python/branches.py | 27 | ||||
| -rw-r--r-- | lua/tests/indent/python/comprehensions.py | 25 | ||||
| -rw-r--r-- | lua/tests/indent/python/control_flow.py | 24 | ||||
| -rw-r--r-- | lua/tests/indent/python/hanging_indent.py | 6 | ||||
| -rw-r--r-- | lua/tests/indent/python/join_lines.py | 8 | ||||
| -rw-r--r-- | lua/tests/indent/python/nested_collections.py | 41 | ||||
| -rw-r--r-- | lua/tests/indent/python/strings.py | 17 | ||||
| -rw-r--r-- | lua/tests/indent/python_spec.lua | 19 |
11 files changed, 215 insertions, 0 deletions
diff --git a/lua/tests/indent/python/aligned_indent.py b/lua/tests/indent/python/aligned_indent.py new file mode 100644 index 000000000..2a4b827f4 --- /dev/null +++ b/lua/tests/indent/python/aligned_indent.py @@ -0,0 +1,11 @@ +def aligned_indent(arg1, + arg2): + pass + +aligned_indent(1, + 2) + + +aligned_indent(1, + 2 + ) diff --git a/lua/tests/indent/python/basic_blocks.py b/lua/tests/indent/python/basic_blocks.py new file mode 100644 index 000000000..4f36359bd --- /dev/null +++ b/lua/tests/indent/python/basic_blocks.py @@ -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 diff --git a/lua/tests/indent/python/basic_collections.py b/lua/tests/indent/python/basic_collections.py new file mode 100644 index 000000000..1582b9059 --- /dev/null +++ b/lua/tests/indent/python/basic_collections.py @@ -0,0 +1,23 @@ +# list +a = [ + 1, 2, + 3 +] + +# set +b = { + 3, + 4, +} + +# dict +c = { + 'a': 'b', + 'c': 1, +} + +# tuple +d = ( + 1, + 2, +) diff --git a/lua/tests/indent/python/branches.py b/lua/tests/indent/python/branches.py new file mode 100644 index 000000000..7ce106bd7 --- /dev/null +++ b/lua/tests/indent/python/branches.py @@ -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 diff --git a/lua/tests/indent/python/comprehensions.py b/lua/tests/indent/python/comprehensions.py new file mode 100644 index 000000000..53c3961e1 --- /dev/null +++ b/lua/tests/indent/python/comprehensions.py @@ -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) +] diff --git a/lua/tests/indent/python/control_flow.py b/lua/tests/indent/python/control_flow.py new file mode 100644 index 000000000..543decc71 --- /dev/null +++ b/lua/tests/indent/python/control_flow.py @@ -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 diff --git a/lua/tests/indent/python/hanging_indent.py b/lua/tests/indent/python/hanging_indent.py new file mode 100644 index 000000000..4d46ebed0 --- /dev/null +++ b/lua/tests/indent/python/hanging_indent.py @@ -0,0 +1,6 @@ +def hanging_indent( + arg1, arg2): + pass + +hanging_indent( + 1, 2) diff --git a/lua/tests/indent/python/join_lines.py b/lua/tests/indent/python/join_lines.py new file mode 100644 index 000000000..491b2cc37 --- /dev/null +++ b/lua/tests/indent/python/join_lines.py @@ -0,0 +1,8 @@ +a = 2 \ + + 2 + +b = 'hello' \ + 'world' + +c = lambda x: \ + x + 3 diff --git a/lua/tests/indent/python/nested_collections.py b/lua/tests/indent/python/nested_collections.py new file mode 100644 index 000000000..292a65a00 --- /dev/null +++ b/lua/tests/indent/python/nested_collections.py @@ -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 + ) diff --git a/lua/tests/indent/python/strings.py b/lua/tests/indent/python/strings.py new file mode 100644 index 000000000..0eb088fa6 --- /dev/null +++ b/lua/tests/indent/python/strings.py @@ -0,0 +1,17 @@ +a = """ + String A +""" + +b = """ +String B +""" + +c = """ + String C + """ + +d = """ + String D +String D + String D + """ diff --git a/lua/tests/indent/python_spec.lua b/lua/tests/indent/python_spec.lua new file mode 100644 index 000000000..9fcdf4637 --- /dev/null +++ b/lua/tests/indent/python_spec.lua @@ -0,0 +1,19 @@ +local whole_file = require('nvim-treesitter.test_utils').indent_whole_file + +describe('indent python', function() + local files = { + 'aligned_indent.py', + 'basic_blocks.py', + 'basic_collections.py', + 'branches.py', + 'comprehensions.py', + 'control_flow.py', + 'hanging_indent.py', + 'join_lines.py', + 'nested_collections.py', + 'strings.py', + } + for _, file in ipairs(files) do + it(file, function() whole_file('lua/tests/indent/python/' .. file) end) + end +end) |
