<s> import unittest <EOL> from Vintageous . ex . parser . parser import parse_command_line <EOL> from Vintageous . ex . parser . scanner import Scanner <EOL> from Vintageous . ex . parser . tokens import TokenDot <EOL> from Vintageous . ex . parser . tokens import TokenSearchForward <EOL> from Vintageous . ex . parser . tokens import TokenSearchBackward <EOL> from Vintageous . ex . parser . tokens import TokenDollar <EOL> from Vintageous . ex . parser . tokens import TokenDigits <EOL> from Vintageous . ex . parser . tokens import TokenPercent <EOL> from Vintageous . ex . parser . tokens import TokenMark <EOL> from Vintageous . ex . parser . tokens import TokenOffset <EOL> from Vintageous . ex . parser . tokens import TokenComma <EOL> from Vintageous . ex . parser . tokens import TokenSemicolon <EOL> class parse_line_ref_Tests ( unittest . TestCase ) : <EOL> def test_CanParseEmpty ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range , None ) <EOL> self . assertEqual ( parsed . command , None ) <EOL> def test_CanParseDotAsStartLine ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:.>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseDotWithOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) , TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseLoneOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_FailsIfDotAfterOffset ( self ) : <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> def test_CanParseMultipleOffsets ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenOffset ( [ <NUM_LIT:10> , <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchForward ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchForward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_SearchForwardClearsPreviousReferences ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) , TokenSearchForward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_SearchForwardClearsPreviousReferencesWithOffsets ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) , TokenOffset ( [ <NUM_LIT:10> ] ) , TokenSearchForward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchBackward ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchBackward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_SearchBackwardClearsPreviousReferences ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) , TokenSearchBackward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_SearchBackwardClearsPreviousReferencesWithOffsets ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) , TokenOffset ( [ <NUM_LIT:10> ] ) , TokenSearchBackward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchForwardWithOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchForward ( '<STR_LIT:foo>' ) , TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchForwardWithOffsets ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchForward ( '<STR_LIT:foo>' ) , TokenOffset ( [ <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchBacwardWithOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchBackward ( '<STR_LIT:foo>' ) , TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseSearchBacwardWithOffsets ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchBackward ( '<STR_LIT:foo>' ) , TokenOffset ( [ <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> def test_CanParseDollarOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:$>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDollar ( ) ] ) <EOL> def test_CanParseDollarWithCompany ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT:0>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDollar ( ) ] ) <EOL> def test_FailsIfDollarOffset ( self ) : <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> def test_FailsIfPrecededByAnything ( self ) : <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> def test_CanParseLoneComma ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:U+002C>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> def test_CanParseDotComma ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> def test_CanParseCommaDot ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> self . assertEqual ( parsed . line_range . start , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDot ( ) ] ) <EOL> def test_CanParseLoneSmicolon ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:;>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanParseDotSmicolon ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDot ( ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanParseSmicolonDot ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDot ( ) ] ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanParseCommaOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> self . assertEqual ( parsed . line_range . start , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> def test_CanParseSemicolonOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> self . assertEqual ( parsed . line_range . start , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end_offset , [ <NUM_LIT:10> ] ) <EOL> def test_CanParseOffsetCommaOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> def test_CanParseSemicolonOffset ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenOffset ( [ <NUM_LIT:10> ] ) ] ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanParseNumber ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT>' ) ] ) <EOL> def test_CanParseNumberRightHandSide ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDigits ( '<STR_LIT>' ) ] ) <EOL> def test_FailsIfDotDigits ( self ) : <EOL> self . assertRaises ( ValueError , parse_command_line , '<STR_LIT>' ) <EOL> class parse_line_ref_TokenComma_Tests ( unittest . TestCase ) : <EOL> def test_CanParseLongSequence ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT:3>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDigits ( '<STR_LIT:4>' ) ] ) <EOL> class parse_line_ref_ParseSubstituteCommand ( unittest . TestCase ) : <EOL> def test_CanParseItOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseAlias ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:s>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithSimpleRange ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT:4>' ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithStartAndEndLines ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT:4>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDigits ( '<STR_LIT:5>' ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithSearchForward ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchForward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithSearchBackward ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchBackward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithSearchBackwardAndSearchForward ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenSearchBackward ( '<STR_LIT:foo>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenSearchForward ( '<STR_LIT:bar>' ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseWithZeroAndDollar ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenDigits ( '<STR_LIT:0>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenDollar ( ) ] ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> class parse_line_ref_Percent ( unittest . TestCase ) : <EOL> def test_CanParsePercent ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT:%>" ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenPercent ( ) ] ) <EOL> class parse_line_ref_SetLineRangeSeparator ( unittest . TestCase ) : <EOL> def test_CanSetComma ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT:U+002C>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> def test_CanSetSemicolon ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT:;>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanSetCommaMultipleTimes ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> def test_CanSetSemicolonMultipleTimes ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanSetMultipleTimesSemicolonLast ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenSemicolon ( ) ) <EOL> def test_CanSetMultipleTimesCommaLast ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . separator , TokenComma ( ) ) <EOL> class parse_line_ref_ParseMarks ( unittest . TestCase ) : <EOL> def test_CanParseItOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenMark ( '<STR_LIT:a>' ) ] ) <EOL> def test_CanParseOnTwoSides ( self ) : <EOL> parsed = parse_command_line ( "<STR_LIT>" ) <EOL> self . assertEqual ( parsed . line_range . start , [ TokenMark ( '<STR_LIT:a>' ) ] ) <EOL> self . assertEqual ( parsed . line_range . end , [ TokenMark ( '<STR_LIT:b>' ) ] ) <EOL> class parse_line_ref_ParseOnlyCommand ( unittest . TestCase ) : <EOL> def test_CanParseItOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseAlias ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> class parse_line_ref_ParseRegistersCommand ( unittest . TestCase ) : <EOL> def test_CanParseItOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseAlias ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> class parse_line_ref_ParseWriteCommand ( unittest . TestCase ) : <EOL> def test_CanParseItOnItsOwn ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) <EOL> def test_CanParseAlias ( self ) : <EOL> parsed = parse_command_line ( '<STR_LIT:w>' ) <EOL> self . assertEqual ( parsed . command . content , '<STR_LIT>' ) </s>
