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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 def testFullRangeMustEndInAlpha(self):
     parser = cmd_line.VimParser('100%,.(')
     self.assertRaises(SyntaxError, parser.parse_full_range)
 def testInFullRangeLineSymbolsCannotHavePrefixOffsets_4(self):
     parser = cmd_line.VimParser('100%,.')
     self.assertRaises(SyntaxError, parser.parse_full_range)
 def testFullRangeCanMatchCommandOnly(self):
     parser = cmd_line.VimParser('foo')
     rv = parser.parse_full_range()
     expected = cmd_line.default_range_info.copy()
     self.assertEqual(rv, expected)
 def testWholeBufferSymbolCannotHavePostfixOffsets(self):
     parser = cmd_line.VimParser('%100')
     self.assertRaises(SyntaxError, parser.parse_range)
 def testWholeBufferSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/%')
     self.assertRaises(SyntaxError, parser.parse_range)
 def testLastLineSymbolCannotHavePrefixOffsets(self):
     parser = cmd_line.VimParser('100$')
     self.assertRaises(SyntaxError, parser.parse_range)
 def testCurrentLineSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/.')
     self.assertRaises(SyntaxError, parser.parse_range)
 def testCanParseEmptyInput(self):
     parser = cmd_line.VimParser('')
     rv = parser.parse_range()
     self.assertEqual(rv, cmd_line.default_range_info)