]> git.madduck.net Git - etc/vim.git/blob - tests/empty_lines.py

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:

acks += miggaiowski
[etc/vim.git] / tests / empty_lines.py
1 """Docstring."""
2
3
4 # leading comment
5 def f():
6     NO = ''
7     SPACE = ' '
8     DOUBLESPACE = '  '
9
10     t = leaf.type
11     p = leaf.parent  # trailing comment
12     v = leaf.value
13
14     if t in ALWAYS_NO_SPACE:
15         pass
16     if t == token.COMMENT:  # another trailing comment
17         return DOUBLESPACE
18
19
20     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
21
22
23     prev = leaf.prev_sibling
24     if not prev:
25         prevp = preceding_leaf(p)
26         if not prevp or prevp.type in OPENING_BRACKETS:
27
28
29             return NO
30
31
32         if prevp.type == token.EQUAL:
33             if prevp.parent and prevp.parent.type in {
34                 syms.typedargslist,
35                 syms.varargslist,
36                 syms.parameters,
37                 syms.arglist,
38                 syms.argument,
39             }:
40                 return NO
41
42         elif prevp.type == token.DOUBLESTAR:
43             if prevp.parent and prevp.parent.type in {
44                 syms.typedargslist,
45                 syms.varargslist,
46                 syms.parameters,
47                 syms.arglist,
48                 syms.dictsetmaker,
49             }:
50                 return NO
51
52 ###############################################################################
53 # SECTION BECAUSE SECTIONS
54 ###############################################################################
55
56 def g():
57     NO = ''
58     SPACE = ' '
59     DOUBLESPACE = '  '
60
61     t = leaf.type
62     p = leaf.parent
63     v = leaf.value
64
65     # Comment because comments
66
67     if t in ALWAYS_NO_SPACE:
68         pass
69     if t == token.COMMENT:
70         return DOUBLESPACE
71
72     # Another comment because more comments
73     assert p is not None, f'INTERNAL ERROR: hand-made leaf without parent: {leaf!r}'
74
75     prev = leaf.prev_sibling
76     if not prev:
77         prevp = preceding_leaf(p)
78
79         if not prevp or prevp.type in OPENING_BRACKETS:
80             # Start of the line or a bracketed expression.
81             # More than one line for the comment.
82             return NO
83
84         if prevp.type == token.EQUAL:
85             if prevp.parent and prevp.parent.type in {
86                 syms.typedargslist,
87                 syms.varargslist,
88                 syms.parameters,
89                 syms.arglist,
90                 syms.argument,
91             }:
92                 return NO
93
94
95 # output
96
97
98 """Docstring."""
99
100
101 # leading comment
102 def f():
103     NO = ""
104     SPACE = " "
105     DOUBLESPACE = "  "
106
107     t = leaf.type
108     p = leaf.parent  # trailing comment
109     v = leaf.value
110
111     if t in ALWAYS_NO_SPACE:
112         pass
113     if t == token.COMMENT:  # another trailing comment
114         return DOUBLESPACE
115
116     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
117
118     prev = leaf.prev_sibling
119     if not prev:
120         prevp = preceding_leaf(p)
121         if not prevp or prevp.type in OPENING_BRACKETS:
122
123             return NO
124
125         if prevp.type == token.EQUAL:
126             if (
127                 prevp.parent
128                 and prevp.parent.type in {
129                     syms.typedargslist,
130                     syms.varargslist,
131                     syms.parameters,
132                     syms.arglist,
133                     syms.argument,
134                 }
135             ):
136                 return NO
137
138         elif prevp.type == token.DOUBLESTAR:
139             if (
140                 prevp.parent
141                 and prevp.parent.type in {
142                     syms.typedargslist,
143                     syms.varargslist,
144                     syms.parameters,
145                     syms.arglist,
146                     syms.dictsetmaker,
147                 }
148             ):
149                 return NO
150
151
152 ###############################################################################
153 # SECTION BECAUSE SECTIONS
154 ###############################################################################
155
156
157 def g():
158     NO = ""
159     SPACE = " "
160     DOUBLESPACE = "  "
161
162     t = leaf.type
163     p = leaf.parent
164     v = leaf.value
165
166     # Comment because comments
167
168     if t in ALWAYS_NO_SPACE:
169         pass
170     if t == token.COMMENT:
171         return DOUBLESPACE
172
173     # Another comment because more comments
174     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
175
176     prev = leaf.prev_sibling
177     if not prev:
178         prevp = preceding_leaf(p)
179
180         if not prevp or prevp.type in OPENING_BRACKETS:
181             # Start of the line or a bracketed expression.
182             # More than one line for the comment.
183             return NO
184
185         if prevp.type == token.EQUAL:
186             if (
187                 prevp.parent
188                 and prevp.parent.type in {
189                     syms.typedargslist,
190                     syms.varargslist,
191                     syms.parameters,
192                     syms.arglist,
193                     syms.argument,
194                 }
195             ):
196                 return NO