Commits

Anonymous committed 9aab59e

inline: fixed inlining occurrences after <=

  • Participants
  • Parent commits 61bcad4

Comments (0)

Files changed (2)

rope/base/worder.py

         single = self.code[next_char:next_char + 1]
         double = self.code[next_char:next_char + 2]
         triple = self.code[next_char:next_char + 3]
-        if double != '==':
+        if double not in ('==', '<=', '>='):
             for op in [single, double, triple]:
                 if op.endswith('='):
                     return op

ropetest/refactor/inlinetest.py

         refactored = self._inline(code, code.rindex('f'))
         self.assertEquals('var = 1 + 1\n', refactored)
 
+    def test_inlining_variables_before_comparison(self):
+        code = 'start = 1\nprint(start <= 2)\n'
+        refactored = self._inline(code, code.index('start'))
+        self.assertEquals('print(1 <= 2)\n', refactored)
+
 
 def suite():
     result = unittest.TestSuite()