AS3Scanner { public void setLines( final String[] linesToBeSet ) { lines = linesToBeSet; line = 0; column = -1; }  Token moveToNextToken(); void setLines( final String[] linesToBeSet );  }
@Test public void testAssignments() { final String[] lines = new String[] { "=", "+=", "-=", "%=", "^=", "&=", "|=", "/=" }; scn.setLines( lines ); for ( int i = 0; i < lines.length; i++ ) { assertText( Integer.toString( i ), lines[ i ] ); assertText( "\n" ); } }
@Test public void testBooleanOperators() { final String[] lines = new String[] { "&&", "&=", "||", "|=" }; scn.setLines( lines ); for ( int i = 0; i < lines.length; i++ ) { assertText( Integer.toString( i ), lines[ i ] ); assertText( "\n" ); } }
@Test public void testComparisonOperators() { final String[] lines = new String[] { ">", ">>>=", ">>>", ">>=", ">>", ">=", "===", "==", "!==", "!=" }; scn.setLines( lines ); for ( int i = 0; i < lines.length; i++ ) { assertText( Integer.toString( i ), lines[ i ] ); assertText( "\n" ); } }
@Test public void testIdentifiers() { final String[] lines = new String[] { "a", "a.b.*", "a.b::c", "a.E" }; scn.setLines( lines ); assertText( "1", lines[ 0 ] ); assertText( "\n" ); assertText( "2", "a" ); assertText( "2", "." ); assertText( "2", "b" ); assertText( "2", "." ); assertText( "2", "*" ); assertText( "\n" ); assertText( "3", "a" ); assertText( "3", "." ); assertText( "3", "b" ); assertText( "3", "::" ); assertText( "3", "c" ); assertText( "\n" ); assertText( "4", "a" ); assertText( "4", "." ); assertText( "4", "E" ); }
@Test public void testMultiLineComment() { final String[] lines = new String[] { "", "" }; scn.setLines( lines ); assertText( lines[ 0 ] ); assertText( "\n" ); assertText( "" ); }
@Test public void testMultilineXML() { final String[] lines = new String[] { "<?xml version=\"1.0\"?>", "<a>", "<b>test</b>", "</a>" }; scn.setLines( lines ); assertText( join( lines, "\n" ) ); }
@Test public void testMultipleWords() { final String[] lines = new String[] { "word1 word2 word3", "word4", "word5 word6" }; scn.setLines( lines ); assertText( "word1" ); assertText( "word2" ); assertText( "word3" ); assertText( "\n" ); assertText( "word4" ); assertText( "\n" ); assertText( "word5" ); assertText( "word6" ); }
@Test public void testNumbers() { final String[] lines = new String[] { "0", "1.2", "1.2E5", "0xffgg" }; scn.setLines( lines ); assertText( lines[ 0 ] ); assertText( "\n" ); assertText( lines[ 1 ] ); assertText( "\n" ); assertText( lines[ 2 ] ); assertText( "\n" ); assertText( lines[ 3 ] ); }
@Test public void testPlusSymbols() { final String[] lines = new String[] { "++", "+=", "+", "--", "-=", "-" }; scn.setLines( lines ); for ( int i = 0; i < lines.length; i++ ) { assertText( Integer.toString( i ), lines[ i ] ); assertText( "\n" ); } }
@Test public void testSingleCharacterSymbols() { final String[] lines = "{}()[]:;,?~".split( "" ); scn.setLines( lines ); for ( int i = 1; i < lines.length; i++ ) { assertText( "\n" ); assertText( Integer.toString( i ), lines[ i ] ); } }
@Test public void testSingleLineComment() { final String[] lines = new String[] { " "word scn.setLines( lines ); assertText( lines[ 0 ] ); assertText( "\n" ); assertText( "word" ); assertText( " }
@Test public void testSingleWord() { final String[] lines = new String[] { "word" }; scn.setLines( lines ); assertText( lines[ 0 ] ); }
@Test public void testStrings() { final String[] lines = new String[] { "\"string\"", "\'string\'", "\"string\\\"\"" }; scn.setLines( lines ); assertText( "1", lines[ 0 ] ); assertText( "\n" ); assertText( "2", lines[ 1 ] ); assertText( "\n" ); assertText( "3", lines[ 2 ] ); }
@Test public void testXML() { final String[] lines = new String[] { "<root/>", "<root>test</root>", "<?xml version=\"1.0\"?><root>test</root>" }; scn.setLines( lines ); for ( int i = 0; i < lines.length; i++ ) { assertText( Integer.toString( i ), lines[ i ] ); assertText( "\n" ); } }