Exemple #1
0
    def testCanSearchMultipleTimesForward(self):
        self.write('''aaa aaa
bbb bbb
ccc cat
ddd ddd
eee eee
fff cat
''')
        self.clear_sel()
        self.add_sel(self.R((0, 0), (0, 0)))
        region = RangeNode(
            start=[TokenSearchForward('cat'),
                   TokenSearchForward('cat')]).resolve(self.view)
        self.assert_equal_regions(self.R(40, 48), region)
 def test_CanParseSearchForwardWithOffsets(self):
     parsed = parse_command_line('/foo/+10+10+10')
     self.assertEqual(
         parsed.line_range.start,
         [TokenSearchForward('foo'),
          TokenOffset([10, 10, 10])])
     self.assertEqual(parsed.line_range.end, [])
 def test_SearchForwardClearsPreviousReferencesWithOffsets(self):
     parsed = parse_command_line('.+10/foo/')
     self.assertEqual(
         parsed.line_range.start,
         [TokenDot(),
          TokenOffset([10]),
          TokenSearchForward('foo')])
     self.assertEqual(parsed.line_range.end, [])
Exemple #4
0
    def testFailedSearchThrows(self):
        self.write('''aaa aaa
bbb bbb
ccc cat
ddd cat
''')
        self.clear_sel()
        self.add_sel(self.R((0, 0), (0, 0)))
        line_range = RangeNode(start=[TokenSearchForward('dog')])
        self.assertRaises(ValueError, line_range.resolve, self.view)
Exemple #5
0
 def testCanScanDotOffsetSearchForward(self):
     scanner = Scanner(".+10/foobar/")
     tokens = list(scanner.scan())
     self.assertEqual([
         TokenDot(),
         TokenOffset([10]),
         TokenSearchForward('foobar'),
         TokenEof()
     ], tokens)
     self.assertEqual(12, scanner.state.position)
Exemple #6
0
    def testCanSearchForwardWithOffset(self):
        self.write('''aaa aaa
bbb bbb
ccc cat
ddd ddd
''')
        self.clear_sel()
        self.add_sel(self.R((0, 0), (0, 0)))
        region = RangeNode(start=[TokenSearchForward('cat'),
                                  TokenOffset([1])]).resolve(self.view)
        self.assert_equal_regions(self.R(24, 32), region)
Exemple #7
0
    def testCanSearchForward(self):
        self.write('''aaa aaa
bbb bbb
ccc cat
ddd cat
''')
        self.clear_sel()
        self.add_sel(self.R((0, 0), (0, 0)))
        region = RangeNode(start=[TokenSearchForward('cat')]).resolve(
            self.view)
        self.assert_equal_regions(self.R(16, 24), region)
Exemple #8
0
 def testCanScanForwardSearch(self):
     scanner = Scanner("/foo/")
     tokens = list(scanner.scan())
     self.assertEqual([TokenSearchForward('foo'), TokenEof()], tokens)
 def test_CanParseSearchForward(self):
     parsed = parse_command_line('/foo/')
     self.assertEqual(parsed.line_range.start, [TokenSearchForward('foo')])
     self.assertEqual(parsed.line_range.end, [])
Exemple #10
0
 def test_CanParseWithSearchBackwardAndSearchForward(self):
     parsed = parse_command_line('?foo?,/bar/s')
     self.assertEqual(parsed.line_range.start, [TokenSearchBackward('foo')])
     self.assertEqual(parsed.line_range.end, [TokenSearchForward('bar')])
     self.assertEqual(parsed.command.content, 'substitute')
Exemple #11
0
 def test_CanParseWithSearchForward(self):
     parsed = parse_command_line('/foo/s')
     self.assertEqual(parsed.line_range.start, [TokenSearchForward('foo')])
     self.assertEqual(parsed.command.content, 'substitute')