public void test_Comment_MixedCodeAndOneLineComments() throws Exception { String source = " some initial code" + EOL + " a second line of code " + EOL + " a third line of code # a comment " + EOL + " some more code" + EOL + " # another comment " + EOL + " a final bit of code"; matcher.extractComments(source); assertEquals( "a comment" + EOL + "another comment" + EOL, DefaultExtractor.commentsAsString(ywdb)); assertEquals( "+----+------+-----------+------------+---------------+" + EOL + "|id |source|line_number|rank_in_line|comment_text |" + EOL + "+----+------+-----------+------------+---------------+" + EOL + "|1 |1 |3 |1 |a comment |" + EOL + "|2 |1 |5 |1 |another comment|" + EOL + "+----+------+-----------+------------+---------------+", FileIO.localizeLineEndings(selectComments().toString())); }
public void test_Bash_OneFullLineComment_SpaceOnEnds() throws Exception { String source = " # a comment "; matcher.extractComments(source); assertEquals("a comment" + EOL, DefaultExtractor.commentsAsString(ywdb)); assertEquals( "+----+------+-----------+------------+------------+" + EOL + "|id |source|line_number|rank_in_line|comment_text|" + EOL + "+----+------+-----------+------------+------------+" + EOL + "|1 |1 |1 |1 |a comment |" + EOL + "+----+------+-----------+------------+------------+", FileIO.localizeLineEndings(selectComments().toString())); }
public void test_Bash_TwoPartialLineComment() throws Exception { String source = " some code # a comment " + EOL + "some more cod # another comment "; matcher.extractComments(source); assertEquals( "a comment" + EOL + "another comment" + EOL, DefaultExtractor.commentsAsString(ywdb)); assertEquals( "+----+------+-----------+------------+---------------+" + EOL + "|id |source|line_number|rank_in_line|comment_text |" + EOL + "+----+------+-----------+------------+---------------+" + EOL + "|1 |1 |1 |1 |a comment |" + EOL + "|2 |1 |2 |1 |another comment|" + EOL + "+----+------+-----------+------------+---------------+", FileIO.localizeLineEndings(selectComments().toString())); }
public void test_Bash_BlankSource_MultiLine() throws Exception { String source = " " + EOL + " " + EOL + " " + EOL; matcher.extractComments(source); assertEquals(0, selectComments().size()); assertEquals("", DefaultExtractor.commentsAsString(ywdb)); }
public void test_Bash_EmptySource() throws Exception { String source = ""; matcher.extractComments(source); assertEquals(0, selectComments().size()); assertEquals("", DefaultExtractor.commentsAsString(ywdb)); }