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

fe86b3854a0e65b1b0620d4c99715ca0199691b6
[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     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
16
17     prev = leaf.prev_sibling
18     if not prev:
19         prevp = preceding_leaf(p)
20         if not prevp or prevp.type in OPENING_BRACKETS:
21
22             return NO
23
24         if prevp.type == token.EQUAL:
25             if prevp.parent and prevp.parent.type in {
26                 syms.typedargslist,
27                 syms.varargslist,
28                 syms.parameters,
29                 syms.arglist,
30                 syms.argument,
31             }:
32                 return NO
33
34         elif prevp.type == token.DOUBLESTAR:
35             if prevp.parent and prevp.parent.type in {
36                 syms.typedargslist,
37                 syms.varargslist,
38                 syms.parameters,
39                 syms.arglist,
40                 syms.dictsetmaker,
41             }:
42                 return NO
43
44
45 ###############################################################################
46 # SECTION BECAUSE SECTIONS
47 ###############################################################################
48
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             return NO
113
114         if prevp.type == token.EQUAL:
115             if prevp.parent and prevp.parent.type in {
116                 syms.typedargslist,
117                 syms.varargslist,
118                 syms.parameters,
119                 syms.arglist,
120                 syms.argument,
121             }:
122                 return NO
123
124         elif prevp.type == token.DOUBLESTAR:
125             if prevp.parent and prevp.parent.type in {
126                 syms.typedargslist,
127                 syms.varargslist,
128                 syms.parameters,
129                 syms.arglist,
130                 syms.dictsetmaker,
131             }:
132                 return NO
133
134
135 ###############################################################################
136 # SECTION BECAUSE SECTIONS
137 ###############################################################################
138 def g():
139     NO = ''
140     SPACE = ' '
141     DOUBLESPACE = '  '
142
143     t = leaf.type
144     p = leaf.parent
145     v = leaf.value
146
147     # Comment because comments
148     if t in ALWAYS_NO_SPACE:
149         pass
150     if t == token.COMMENT:
151         return DOUBLESPACE
152
153     # Another comment because more comments
154     assert p is not None, f"INTERNAL ERROR: hand-made leaf without parent: {leaf!r}"
155
156     prev = leaf.prev_sibling
157     if not prev:
158         prevp = preceding_leaf(p)
159
160         if not prevp or prevp.type in OPENING_BRACKETS:
161             # Start of the line or a bracketed expression.
162             # More than one line for the comment.
163             return NO
164
165         if prevp.type == token.EQUAL:
166             if prevp.parent and prevp.parent.type in {
167                 syms.typedargslist,
168                 syms.varargslist,
169                 syms.parameters,
170                 syms.arglist,
171                 syms.argument,
172             }:
173                 return NO