예제 #1
0
 def testBackward(self):
     ca = CircularArray(list(range(0, 5)))
     self.assertEqual(ca.backward(), 4)
     self.assertEqual(ca.backward(), 3)
     self.assertEqual(ca.backward(), 2)
     self.assertEqual(ca.backward(), 1)
     self.assertEqual(ca.backward(), 0)
     self.assertEqual(ca.backward(), 4)
예제 #2
0
 def xtestBidirectionality(self):
     ca = CircularArray(list(range(0, 5)))
     self.assertEqual(ca.backward(), 4)
     self.assertEqual(ca.forward(), 0)
     self.assertEqual(ca.backward(), 4)
     self.assertEqual(ca.forward(), 0)
     self.assertEqual(ca.forward(), 1)
     self.assertEqual(ca.forward(), 2)
     self.assertEqual(ca.forward(), 3)
     self.assertEqual(ca.forward(), 4)
     self.assertEqual(ca.backward(), 3)
     self.assertEqual(ca.backward(), 2)
     self.assertEqual(ca.backward(), 1)
     self.assertEqual(ca.backward(), 0)
예제 #3
0
    def run(self, edit, reverse=False):
        path = self.view.substr(sublime.Region(0, self.view.size()))

        if not DartCompleteFs.cache or DartCompleteFs.user_interaction:
            DartCompleteFs.user_interaction = False
            DartCompleteFs.index = 0
            DartCompleteFs.locked_dir = os.path.dirname(path)

            items = DartCompleteFs.fs_completer.get_completions(
                                                           path,
                                                           force_refresh=True)

            DartCompleteFs.cache = CircularArray(items)

        if len(DartCompleteFs.cache) == 0:
            DartCompleteFs.index = 0
            return

        item = DartCompleteFs.cache.forward() if not reverse \
                                              else DartCompleteFs.cache.backward()
        content = os.path.join(DartCompleteFs.locked_dir, item)

        self.view.erase(edit, sublime.Region(0, self.view.size()))
        # Change event of input panel runs async, so make sure it knows this
        # time it was a non-interactive change.
        DartStagehand.cancel_change_event = True
        self.view.run_command('append', {'characters': content})

        self.view.sel().clear()
        self.view.sel().add(sublime.Region(self.view.size()))
예제 #4
0
 def testCanInstantiate(self):
     ca = CircularArray(list(range(0, 5)))
     self.assertEqual(len(ca), 5)