예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #20
0
 def testCanHaveMultipleSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo//bar/?baz?')
     rv = parser.parse_range()
     expected = cmd_line.default_range_info.copy()
     expected['left_search_offsets'] = [
         ['/', 'foo', 0],
         ['/', 'bar', 0],
         ['?', 'baz', 0],
     ]
     expected['text_range'] = '/foo//bar/?baz?'
     self.assertEqual(rv, expected)
예제 #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)
예제 #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)
예제 #23
0
 def testFullRangeMustEndInAlpha(self):
     parser = cmd_line.VimParser('100%,.(')
     self.assertRaises(SyntaxError, parser.parse_full_range)
예제 #24
0
 def testInFullRangeLineSymbolsCannotHavePrefixOffsets_4(self):
     parser = cmd_line.VimParser('100%,.')
     self.assertRaises(SyntaxError, parser.parse_full_range)
예제 #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)
예제 #26
0
 def testWholeBufferSymbolCannotHavePostfixOffsets(self):
     parser = cmd_line.VimParser('%100')
     self.assertRaises(SyntaxError, parser.parse_range)
예제 #27
0
 def testWholeBufferSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/%')
     self.assertRaises(SyntaxError, parser.parse_range)
예제 #28
0
 def testLastLineSymbolCannotHavePrefixOffsets(self):
     parser = cmd_line.VimParser('100$')
     self.assertRaises(SyntaxError, parser.parse_range)
예제 #29
0
 def testCurrentLineSymbolCannotHavePrefixSearchBasedOffsets(self):
     parser = cmd_line.VimParser('/foo/.')
     self.assertRaises(SyntaxError, parser.parse_range)
예제 #30
0
 def testCanParseEmptyInput(self):
     parser = cmd_line.VimParser('')
     rv = parser.parse_range()
     self.assertEqual(rv, cmd_line.default_range_info)