| 1 | # -------------------------------------------------- no-name-error |
| 2 | #? 0 error |
| 3 | 1 |
| 4 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 5 | There is no name under the cursor |
| 6 | # -------------------------------------------------- no-reference-error |
| 7 | #? 0 error |
| 8 | a = 1 |
| 9 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 10 | There are no references to this name |
| 11 | # -------------------------------------------------- multi-equal-error |
| 12 | def test(): |
| 13 | #? 4 error |
| 14 | a = b = 3 |
| 15 | return test(100, a) |
| 16 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 17 | Cannot inline a statement with multiple definitions |
| 18 | # -------------------------------------------------- no-definition-error |
| 19 | #? 5 error |
| 20 | test(a) |
| 21 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 22 | No definition found to inline |
| 23 | # -------------------------------------------------- multi-names-error |
| 24 | #? 0 error |
| 25 | a, b[1] = 3 |
| 26 | test(a) |
| 27 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 28 | Cannot inline a statement with multiple definitions |
| 29 | # -------------------------------------------------- addition-error |
| 30 | #? 0 error |
| 31 | a = 2 |
| 32 | a += 3 |
| 33 | test(a) |
| 34 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 35 | Cannot inline a name with multiple definitions |
| 36 | # -------------------------------------------------- only-addition-error |
| 37 | #? 0 error |
| 38 | a += 3 |
| 39 | test(a) |
| 40 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 41 | Cannot inline a statement with "+=" |
| 42 | # -------------------------------------------------- with-annotation |
| 43 | foobarb: int = 1 |
| 44 | #? 5 |
| 45 | test(foobarb) |
| 46 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 47 | --- inline.py |
| 48 | +++ inline.py |
| 49 | @@ -1,4 +1,3 @@ |
| 50 | -foobarb: int = 1 |
| 51 | #? 5 |
| 52 | -test(foobarb) |
| 53 | +test(1) |
| 54 | # -------------------------------------------------- only-annotation-error |
| 55 | a: int |
| 56 | #? 5 error |
| 57 | test(a) |
| 58 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 59 | Cannot inline a statement that is defined by an annotation |
| 60 | # -------------------------------------------------- builtin |
| 61 | import math |
| 62 | #? 7 error |
| 63 | math.cos |
| 64 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 65 | Cannot inline builtins/extensions |
| 66 | # -------------------------------------------------- module-error |
| 67 | from import_tree import inline_mod |
| 68 | #? 11 error |
| 69 | test(inline_mod) |
| 70 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 71 | Cannot inline imports, modules or namespaces |
| 72 | # -------------------------------------------------- module-works |
| 73 | from import_tree import inline_mod |
| 74 | #? 22 |
| 75 | test(x, inline_mod. inline_var.conjugate) |
| 76 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 77 | --- import_tree/inline_mod.py |
| 78 | +++ import_tree/inline_mod.py |
| 79 | @@ -1,2 +1 @@ |
| 80 | -inline_var = 5 + 3 |
| 81 | --- inline.py |
| 82 | +++ inline.py |
| 83 | @@ -1,4 +1,4 @@ |
| 84 | from import_tree import inline_mod |
| 85 | #? 22 |
| 86 | -test(x, inline_mod. inline_var.conjugate) |
| 87 | +test(x, (5 + 3).conjugate) |
| 88 | # -------------------------------------------------- class |
| 89 | class A: pass |
| 90 | #? 5 error |
| 91 | test(A) |
| 92 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 93 | Cannot inline a class |
| 94 | # -------------------------------------------------- function |
| 95 | def foo(a): |
| 96 | return a + 1 |
| 97 | #? 5 error |
| 98 | test(foo(1)) |
| 99 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 100 | Cannot inline a function |
| 101 | # -------------------------------------------------- for-stmt |
| 102 | for x in []: |
| 103 | #? 9 error |
| 104 | test(x) |
| 105 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 106 | Cannot inline a for_stmt |
| 107 | # -------------------------------------------------- simple |
| 108 | def test(): |
| 109 | #? 4 |
| 110 | a = (30 + b, c) + 1 |
| 111 | return test(100, a) |
| 112 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 113 | --- inline.py |
| 114 | +++ inline.py |
| 115 | @@ -1,5 +1,4 @@ |
| 116 | def test(): |
| 117 | #? 4 |
| 118 | - a = (30 + b, c) + 1 |
| 119 | - return test(100, a) |
| 120 | + return test(100, (30 + b, c) + 1) |
| 121 | # -------------------------------------------------- tuple |
| 122 | if 1: |
| 123 | #? 4 |
| 124 | a = 1, 2 |
| 125 | return test(100, a) |
| 126 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 127 | --- inline.py |
| 128 | +++ inline.py |
| 129 | @@ -1,5 +1,4 @@ |
| 130 | if 1: |
| 131 | #? 4 |
| 132 | - a = 1, 2 |
| 133 | - return test(100, a) |
| 134 | + return test(100, (1, 2)) |
| 135 | # -------------------------------------------------- multiplication-add-parens1 |
| 136 | a = 1+2 |
| 137 | #? 11 |
| 138 | test(100 * a) |
| 139 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 140 | --- inline.py |
| 141 | +++ inline.py |
| 142 | @@ -1,4 +1,3 @@ |
| 143 | -a = 1+2 |
| 144 | #? 11 |
| 145 | -test(100 * a) |
| 146 | +test(100 * (1+2)) |
| 147 | # -------------------------------------------------- multiplication-add-parens2 |
| 148 | a = 1+2 |
| 149 | #? 11 |
| 150 | (x, 100 * a) |
| 151 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 152 | --- inline.py |
| 153 | +++ inline.py |
| 154 | @@ -1,4 +1,3 @@ |
| 155 | -a = 1+2 |
| 156 | #? 11 |
| 157 | -(x, 100 * a) |
| 158 | +(x, 100 * (1+2)) |
| 159 | # -------------------------------------------------- multiplication-add-parens3 |
| 160 | x |
| 161 | a = 1+2 |
| 162 | #? 9 |
| 163 | (100 ** a) |
| 164 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 165 | --- inline.py |
| 166 | +++ inline.py |
| 167 | @@ -1,5 +1,4 @@ |
| 168 | x |
| 169 | -a = 1+2 |
| 170 | #? 9 |
| 171 | -(100 ** a) |
| 172 | +(100 ** (1+2)) |
| 173 | # -------------------------------------------------- no-add-parens1 |
| 174 | x |
| 175 | a = 1+2 |
| 176 | #? 5 |
| 177 | test(a) |
| 178 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 179 | --- inline.py |
| 180 | +++ inline.py |
| 181 | @@ -1,5 +1,4 @@ |
| 182 | x |
| 183 | -a = 1+2 |
| 184 | #? 5 |
| 185 | -test(a) |
| 186 | +test(1+2) |
| 187 | # -------------------------------------------------- no-add-parens2 |
| 188 | a = 1+2 |
| 189 | #? 9 |
| 190 | test(3, a) |
| 191 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 192 | --- inline.py |
| 193 | +++ inline.py |
| 194 | @@ -1,4 +1,3 @@ |
| 195 | -a = 1+2 |
| 196 | #? 9 |
| 197 | -test(3, a) |
| 198 | +test(3, 1+2) |
| 199 | # -------------------------------------------------- no-add-parens3 |
| 200 | a = 1|2 |
| 201 | #? 5 |
| 202 | (3, a) |
| 203 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 204 | --- inline.py |
| 205 | +++ inline.py |
| 206 | @@ -1,4 +1,3 @@ |
| 207 | -a = 1|2 |
| 208 | #? 5 |
| 209 | -(3, a) |
| 210 | +(3, 1|2) |
| 211 | # -------------------------------------------------- comment |
| 212 | a = 1 and 2 # foo |
| 213 | #? 9 |
| 214 | (3, 3 * a) |
| 215 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 216 | --- inline.py |
| 217 | +++ inline.py |
| 218 | @@ -1,4 +1,4 @@ |
| 219 | -a = 1 and 2 # foo |
| 220 | + # foo |
| 221 | #? 9 |
| 222 | -(3, 3 * a) |
| 223 | +(3, 3 * (1 and 2)) |
| 224 | # -------------------------------------------------- semicolon |
| 225 | a = 1, 2 ; b = 3 |
| 226 | #? 9 |
| 227 | (3, 3 == a) |
| 228 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 229 | --- inline.py |
| 230 | +++ inline.py |
| 231 | @@ -1,4 +1,4 @@ |
| 232 | -a = 1, 2 ; b = 3 |
| 233 | + b = 3 |
| 234 | #? 9 |
| 235 | -(3, 3 == a) |
| 236 | +(3, 3 == (1, 2)) |
| 237 | # -------------------------------------------------- no-tree-name |
| 238 | a = 1 + 2 |
| 239 | #? 0 |
| 240 | a.conjugate |
| 241 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 242 | --- inline.py |
| 243 | +++ inline.py |
| 244 | @@ -1,4 +1,3 @@ |
| 245 | -a = 1 + 2 |
| 246 | #? 0 |
| 247 | -a.conjugate |
| 248 | +(1 + 2).conjugate |