]> 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:

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