]> git.madduck.net Git - etc/vim.git/blob - test/fixers/test_python_add_blank_lines_fixer.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / fixers / test_python_add_blank_lines_fixer.vader
1 Before:
2   Save g:ale_fixers
3
4 After:
5   Restore
6
7 Given python(Some Python without blank lines):
8   def foo():
9       """ This is a simple test docstring """
10       return 1
11
12
13   def bar():
14       '''This is another simple test docstring'''
15       return 1
16       return 4
17
18
19   def bar():
20       """
21       This is a multi-line
22       docstring
23       """
24
25       if x:
26           pass
27           for l in x:
28               pass
29           for l in x:
30               pass
31               break
32               continue
33       elif x:
34           pass
35           while x:
36               pass
37           while x:
38               pass
39       else:
40           pass
41       if x:
42           pass
43       elif x:
44           pass
45       else:
46           pass
47
48 Execute(Blank lines should be added appropriately):
49   let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
50   ALEFix
51
52 Expect python(Newlines should be added):
53   def foo():
54       """ This is a simple test docstring """
55
56       return 1
57
58
59   def bar():
60       '''This is another simple test docstring'''
61
62       return 1
63
64       return 4
65
66
67   def bar():
68       """
69       This is a multi-line
70       docstring
71       """
72
73       if x:
74           pass
75
76           for l in x:
77               pass
78
79           for l in x:
80               pass
81
82               break
83
84               continue
85       elif x:
86           pass
87
88           while x:
89               pass
90
91           while x:
92               pass
93       else:
94           pass
95
96       if x:
97           pass
98       elif x:
99           pass
100       else:
101           pass
102
103 Given python(A file with a main block):
104   import os
105
106
107   def main():
108       print('hello')
109
110
111   if __name__ == '__main__':
112       main()
113
114 Execute(Fix the file):
115   let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
116   ALEFix
117
118 Expect python(extra newlines shouldn't be added to the main block):
119   import os
120
121
122   def main():
123       print('hello')
124
125
126   if __name__ == '__main__':
127       main()
128
129
130 Given python(A file with variables/docstring that start with a control statement):
131   def some():
132       """
133       This is a docstring that contains an
134       break control statement and also contains a
135       return something funny.
136       """
137
138       continue_some_var = True
139       forward_something = False
140
141       if (
142           continue_some_var and
143           forwarded_something
144       ):
145           return True
146
147
148 Execute(Fix the file):
149   let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
150   ALEFix
151
152 Expect python(Extra new lines are not added to the file):
153   def some():
154       """
155       This is a docstring that contains an
156       break control statement and also contains a
157       return something funny.
158       """
159
160       continue_some_var = True
161       forward_something = False
162
163       if (
164           continue_some_var and
165           forwarded_something
166       ):
167           return True