Esempio n. 1
0
 def testSearchBasedOffsetsCanEscapeQuestionMark(self):
     parser = cmd_line.VimParser('?foo\?-100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['?', 'foo?-100', 0]]
     expected['text_range'] = '?foo\?-100'
     self.assertEqual(rv, expected)
Esempio n. 2
0
 def testSearchBasedOffsetsEscapeAnyUnknownEscapeSequence(self):
     parser = cmd_line.VimParser('/foo\\h')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['/', 'fooh', 0]]
     expected['text_range'] = '/foo\\h'
     self.assertEqual(rv, expected)
Esempio n. 3
0
 def testCanMatchSearchBasedOffsetsWithSignedIntegerOffset(self):
     parser = cmd_line.VimParser('/foo/-100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['/', 'foo', -100]]
     expected['text_range'] = '/foo/-100'
     self.assertEqual(rv, expected)
Esempio n. 4
0
 def testCanMatchLastLineSymbol(self):
     parser = cmd_line.VimParser('$')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '$'
     expected['text_range'] = '$'
     self.assertEqual(rv, expected)
Esempio n. 5
0
 def testCanMatchReverseSearchBasedOffsetsWithPostfixOffset(self):
     parser = cmd_line.VimParser('?foo?100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['?', 'foo', 100]]
     expected['text_range'] = '?foo?100'
     self.assertEqual(rv, expected)
Esempio n. 6
0
 def testCanMatchPlusSignOffset(self):
     parser = cmd_line.VimParser('+')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_offset'] = 1
     expected['text_range'] = '+'
     self.assertEqual(rv, expected)
Esempio n. 7
0
 def testCanMatchUppsercaseMarkRef(self):
     parser = cmd_line.VimParser("'A")
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = "'A"
     expected['text_range'] = "'A"
     self.assertEqual(rv, expected)
Esempio n. 8
0
 def testCanMatchWholeBufferSymbol(self):
     parser = cmd_line.VimParser('%')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '%'
     expected['text_range'] = '%'
     self.assertEqual(rv, expected)
Esempio n. 9
0
 def testSearchBasedOffsetsCanEscapeBackSlash(self):
     parser = cmd_line.VimParser('/foo\\\\?-100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['/', 'foo\\?-100', 0]]
     expected['text_range'] = '/foo\\\\?-100'
     self.assertEqual(rv, expected)
Esempio n. 10
0
 def testCanMatchPostFixMinusSign(self):
     parser = cmd_line.VimParser('101-')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_offset'] = 100
     expected['text_range'] = '101-'
     self.assertEqual(rv, expected)
Esempio n. 11
0
 def testCurrentLineSymbolCanHavePostfixSignOffsets(self):
     parser = cmd_line.VimParser('.+')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = 1
     expected['text_range'] = '.+'
     self.assertEqual(rv, expected)
Esempio n. 12
0
 def testLastLineSymbolCanHavePostfixSignedIntegerOffsets(self):
     parser = cmd_line.VimParser('$+100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '$'
     expected['left_offset'] = 100
     expected['text_range'] = '$+100'
     self.assertEqual(rv, expected)
Esempio n. 13
0
 def testCanMatchPlusSignBeforeNegativeInteger(self):
     parser = cmd_line.VimParser('+-101')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = -100 
     expected['text_range'] = '+-101'
     self.assertEqual(rv, expected)
Esempio n. 14
0
 def testCanMatchMultipleMinusSignsOffset(self):
     parser = cmd_line.VimParser('--')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = -2
     expected['text_range'] = '--'
     self.assertEqual(rv, expected)
Esempio n. 15
0
 def testCanMatchPositiveIntegerOffset(self):
     parser = cmd_line.VimParser('+100')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.' 
     expected['left_offset'] = 100 
     expected['text_range'] = "+100"
     self.assertEqual(rv, expected)
Esempio n. 16
0
 def testLastLineSymbolCanHavePostfixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('$?foo?+10')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '$'
     expected['left_search_offsets'] = [['?', 'foo', 10]]
     expected['text_range'] = '$?foo?+10'
     self.assertEqual(rv, expected)
Esempio n. 17
0
 def testCanMatchMultipleSignsAndNegativeIntegerOffset(self):
     parser = cmd_line.VimParser('--99')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = -100 
     expected['text_range'] = '--99'
     self.assertEqual(rv, expected)
Esempio n. 18
0
 def testCanMatchFullRangeOfIntegersSymbols_2(self):
     parser = cmd_line.VimParser('.,%')
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['separator'] = ','
     expected['right_ref'] = '%'
     self.assertEqual(rv, expected)
Esempio n. 19
0
 def testCanMatchFullRangeOfIntegers(self):
     parser = cmd_line.VimParser('100,100')
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_offset'] = 100
     expected['separator'] = ','
     expected['right_offset'] = 100
     expected['text_range'] = '100,100'
     self.assertEqual(rv, expected)
Esempio n. 20
0
 def testCanHaveMultipleSearchBasedOffsetsWithInterspersedNumericOffets(self):
     parser = cmd_line.VimParser('/foo/100/bar/+100--+++?baz?')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [['/', 'foo', 100],
                                        ['/', 'bar', 101],
                                        ['?', 'baz', 0],
                                       ]
     expected['text_range'] = '/foo/100/bar/+100--+++?baz?'
     self.assertEqual(rv, expected)
Esempio n. 21
0
 def testCanMatchFullRangeOfIntegersWithOffsets(self):
     parser = cmd_line.VimParser('+100++--+;++100-')
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = 101
     expected['separator'] = ';'
     expected['right_ref'] = '.'
     expected['right_offset'] = 100
     expected['text_range'] = '+100++--+;++100-'
     self.assertEqual(rv, expected)
Esempio n. 22
0
 def testComplexFullRange(self):
     parser = cmd_line.VimParser(".++9/foo\\bar/100?baz?--;'b-100?buzz\\\\\\??+10")
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_ref'] = '.'
     expected['left_offset'] = 10
     expected['left_search_offsets'] = [['/', 'foobar', 100], ['?', 'baz', -2]]
     expected['separator'] = ';'
     expected['right_ref'] = "'b"
     expected['right_offset'] = -100
     expected['right_search_offsets'] = [['?', 'buzz\\?', 10]]
     expected['text_range'] = ".++9/foo\\bar/100?baz?--;'b-100?buzz\\\\\\??+10"
     self.assertEqual(rv, expected)
Esempio n. 23
0
 def testFullRangeMustEndInAlpha(self):
     parser = cmd_line.VimParser('100%,.(')
     self.assertRaises(SyntaxError, parser.parse_full_range)
Esempio n. 24
0
 def testInFullRangeLineSymbolsCannotHavePrefixOffsets_4(self):
     parser = cmd_line.VimParser('100%,.')
     self.assertRaises(SyntaxError, parser.parse_full_range)
Esempio n. 25
0
 def testFullRangeCanMatchCommandOnly(self):
     parser = cmd_line.VimParser('foo')
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     self.assertEqual(rv, expected)
Esempio n. 26
0
 def testWholeBufferSymbolCannotHavePostfixOffsets(self):
     parser = cmd_line.VimParser('%100')
     self.assertRaises(SyntaxError, parser.parse_range)
Esempio n. 27
0
 def testWholeBufferSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/%')
     self.assertRaises(SyntaxError, parser.parse_range)
Esempio n. 28
0
 def testLastLineSymbolCannotHavePrefixOffsets(self):
     parser = cmd_line.VimParser('100$')
     self.assertRaises(SyntaxError, parser.parse_range)
Esempio n. 29
0
 def testCurrentLineSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/.')
     self.assertRaises(SyntaxError, parser.parse_range)
Esempio n. 30
0
 def testCanParseEmptyInput(self):
     parser = cmd_line.VimParser('')
     rv = parser.parse_range()
     self.assertEqual(rv, cmd_line.default_range_info)