Beispiel #1
0
 def test_oneLine(self):
     buf = self.fooBuf
     VeryHint.forBuffer(buf).showHints(["biz, baz"], buf.cursor)
     self.assertEquals(buf[0], "bar{ biz, baz }")
     self.assertEquals(buf.edits, 1)
     VeryHint.forBuffer(buf).hideHints()
     self.assertEquals(buf[0], "bars")
     self.assertEquals(buf.edits, 2)
Beispiel #2
0
 def test_noRoom(self):
     """No room? Just show nothing; rare case anyway"""
     buf = DummyBuffer("foo(|)")
     VeryHint.forBuffer(buf).showHints(["biz, baz"], buf.cursor)
     self.assertEquals(buf[0], "foo()")
     self.assertEquals(buf.edits, 0)
     VeryHint.forBuffer(buf).hideHints()
     self.assertEquals(buf[0], "foo()")
     self.assertEquals(buf.edits, 0)
Beispiel #3
0
 def test_duck(self):
     buf = self.fooBuf
     VeryHint.forBuffer(buf).showHints(["biz, baz"], buf.cursor)
     self.assertEquals(buf[0], "bar{ biz, baz }")
     VeryHint.forBuffer(buf).duck()
     self.assertEquals(buf[0], "bars")
     VeryHint.forBuffer(buf).unduck()
     self.assertEquals(buf[0], "bar{ biz, baz }")
     VeryHint.forBuffer(buf).hideHints()
     self.assertEquals(buf[0], "bars")
Beispiel #4
0
    def test_twoLines(self):
        line1 = 'Ship serenity = new Ship();'
        line2 = 'serenity.setName("Serenity").setType("Firefly");'
        line3 = 'serenity.addCrew(|'
        buf = DummyBuffer([line1, line2, line3])

        VeryHint.forBuffer(buf).showHints(
            ["String name, Job job", "Crew crew"], buf.cursor)
        self.assertEquals(buf[0], "Ship serenity = { String name, Job job }")
        self.assertEquals(
            buf[1], 'serenity.setName{ Crew crew            }Firefly");')
        self.assertEquals(buf[2], line3[:-1])  # strip the "cursor"
        self.assertEquals(buf.edits, 2)
        VeryHint.forBuffer(buf).hideHints()
        self.assertEquals(buf[0], line1)
        self.assertEquals(buf[1], line2)
        self.assertEquals(buf[2], line3[:-1])
        self.assertEquals(buf.edits, 4)
Beispiel #5
0
    def test_noChangeNoEdits(self):
        line1 = 'Ship serenity = new Ship();'
        line2 = 'serenity.setName("Serenity").setType("Firefly");'
        line3 = 'serenity.addCrew(|'
        buf = DummyBuffer([line1, line2, line3])

        VeryHint.forBuffer(buf).showHints(
            ["String name, Job job", "Crew crew"], buf.cursor)
        self.assertEquals(buf.edits, 2)

        # type something
        buf[2] = 'serenity.addCrew(C'
        self.assertEquals(buf.edits, 3)

        # re-show at same spot, no edits
        VeryHint.forBuffer(buf).showHints(
            ["String name, Job job", "Crew crew"],
            buf.cursor)  # NB cursor hasn't changed
        self.assertEquals(buf.edits, 3)
Beispiel #6
0
 def tearDown(self):
     VeryHint.FORMAT = self._originalFormat
     VeryHint.cleanup()
Beispiel #7
0
    def test_pad(self):
        buf = DummyBuffer(['i++', 'getCrew(|'])

        # space should be added after the i++ so it aligns
        VeryHint.forBuffer(buf).showHints(["int index"], buf.cursor)
        self.assertEquals(buf[0], "i++    { int index }")
Beispiel #8
0
    def test_redunDuck(self):
        buf = self.fooBuf
        VeryHint.forBuffer(buf).duck()
        self.assertEquals(buf[0], "bars")  # no changes, no errors

        VeryHint.forBuffer(buf).showHints(["biz, baz"], buf.cursor)
        self.assertEquals(buf[0], "bar{ biz, baz }")

        VeryHint.forBuffer(buf).duck()
        self.assertEquals(buf[0], "bars")

        # still the same:
        VeryHint.forBuffer(buf).duck()
        self.assertEquals(buf[0], "bars")

        VeryHint.forBuffer(buf).unduck()
        self.assertEquals(buf[0], "bar{ biz, baz }")

        # no confusion please
        VeryHint.forBuffer(buf).unduck()
        self.assertEquals(buf[0], "bar{ biz, baz }")

        VeryHint.forBuffer(buf).hideHints()
        self.assertEquals(buf[0], "bars")