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

Fix tests on windows (#159)
[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 (
117                 prevp.parent
118                 and prevp.parent.type in {
119                     syms.typedargslist,
120                     syms.varargslist,
121                     syms.parameters,
122                     syms.arglist,
123                     syms.argument,
124                 }
125             ):
126                 return NO
127
128         elif prevp.type == token.DOUBLESTAR:
129             if (
130                 prevp.parent
131                 and prevp.parent.type in {
132                     syms.typedargslist,
133                     syms.varargslist,
134                     syms.parameters,
135                     syms.arglist,
136                     syms.dictsetmaker,
137                 }
138             ):
139                 return NO
140
141
142 ###############################################################################
143 # SECTION BECAUSE SECTIONS
144 ###############################################################################
145
146
147 def g():
148     NO = ""
149     SPACE = " "
150     DOUBLESPACE = "  "
151
152     t = leaf.type
153     p = leaf.parent
154     v = leaf.value
155
156     # Comment because comments
157
158     if t in ALWAYS_NO_SPACE:
159         pass
160     if t == token.COMMENT:
161         return DOUBLESPACE
162
163     # Another comment because more comments
164     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
165
166     prev = leaf.prev_sibling
167     if not prev:
168         prevp = preceding_leaf(p)
169
170         if not prevp or prevp.type in OPENING_BRACKETS:
171             # Start of the line or a bracketed expression.
172             # More than one line for the comment.
173             return NO
174
175         if prevp.type == token.EQUAL:
176             if (
177                 prevp.parent
178                 and prevp.parent.type in {
179                     syms.typedargslist,
180                     syms.varargslist,
181                     syms.parameters,
182                     syms.arglist,
183                     syms.argument,
184                 }
185             ):
186                 return NO