Show More
@@ -192,13 +192,42 b' class InputSplitterTestCase(unittest.TestCase):' | |||
|
192 | 192 | isp.push(" x = (1+\n 2)") |
|
193 | 193 | self.assertEqual(isp.indent_spaces, 4) |
|
194 | 194 | |
|
195 | def test_dedent(self): | |
|
195 | def test_dedent_pass(self): | |
|
196 | 196 | isp = self.isp # shorthand |
|
197 | isp.push('if 1:') | |
|
197 | # should NOT cause dedent | |
|
198 | isp.push('if 1:\n passes = 5') | |
|
198 | 199 | self.assertEqual(isp.indent_spaces, 4) |
|
199 | isp.push(' pass') | |
|
200 | isp.push('if 1:\n pass') | |
|
200 | 201 | self.assertEqual(isp.indent_spaces, 0) |
|
201 | ||
|
202 | isp.push('if 1:\n pass ') | |
|
203 | self.assertEqual(isp.indent_spaces, 0) | |
|
204 | ||
|
205 | def test_dedent_raise(self): | |
|
206 | isp = self.isp # shorthand | |
|
207 | # should NOT cause dedent | |
|
208 | isp.push('if 1:\n raised = 4') | |
|
209 | self.assertEqual(isp.indent_spaces, 4) | |
|
210 | isp.push('if 1:\n raise TypeError()') | |
|
211 | self.assertEqual(isp.indent_spaces, 0) | |
|
212 | isp.push('if 1:\n raise') | |
|
213 | self.assertEqual(isp.indent_spaces, 0) | |
|
214 | isp.push('if 1:\n raise ') | |
|
215 | self.assertEqual(isp.indent_spaces, 0) | |
|
216 | ||
|
217 | def test_dedent_return(self): | |
|
218 | isp = self.isp # shorthand | |
|
219 | # should NOT cause dedent | |
|
220 | isp.push('if 1:\n returning = 4') | |
|
221 | self.assertEqual(isp.indent_spaces, 4) | |
|
222 | isp.push('if 1:\n return 5 + 493') | |
|
223 | self.assertEqual(isp.indent_spaces, 0) | |
|
224 | isp.push('if 1:\n return') | |
|
225 | self.assertEqual(isp.indent_spaces, 0) | |
|
226 | isp.push('if 1:\n return ') | |
|
227 | self.assertEqual(isp.indent_spaces, 0) | |
|
228 | isp.push('if 1:\n return(0)') | |
|
229 | self.assertEqual(isp.indent_spaces, 0) | |
|
230 | ||
|
202 | 231 | def test_push(self): |
|
203 | 232 | isp = self.isp |
|
204 | 233 | self.assertTrue(isp.push('x=1')) |
General Comments 0
You need to be logged in to leave comments.
Login now