Show More
@@ -192,11 +192,40 b' class InputSplitterTestCase(unittest.TestCase):' | |||||
192 | isp.push(" x = (1+\n 2)") |
|
192 | isp.push(" x = (1+\n 2)") | |
193 | self.assertEqual(isp.indent_spaces, 4) |
|
193 | self.assertEqual(isp.indent_spaces, 4) | |
194 |
|
194 | |||
195 | def test_dedent(self): |
|
195 | def test_dedent_pass(self): | |
196 | isp = self.isp # shorthand |
|
196 | isp = self.isp # shorthand | |
197 | isp.push('if 1:') |
|
197 | # should NOT cause dedent | |
|
198 | isp.push('if 1:\n passes = 5') | |||
|
199 | self.assertEqual(isp.indent_spaces, 4) | |||
|
200 | isp.push('if 1:\n pass') | |||
|
201 | self.assertEqual(isp.indent_spaces, 0) | |||
|
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') | |||
198 | self.assertEqual(isp.indent_spaces, 4) |
|
209 | self.assertEqual(isp.indent_spaces, 4) | |
199 |
isp.push(' |
|
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)') | |||
200 | self.assertEqual(isp.indent_spaces, 0) |
|
229 | self.assertEqual(isp.indent_spaces, 0) | |
201 |
|
230 | |||
202 | def test_push(self): |
|
231 | def test_push(self): |
General Comments 0
You need to be logged in to leave comments.
Login now