Added unit tests for block comments.

This commit is contained in:
Maikel Steneker
2019-05-10 16:10:03 +02:00
parent 735b5305ac
commit 224c3931e4

View File

@@ -68,4 +68,22 @@ public class MatlabTokenizerTest extends AbstractTokenizerTest {
TokenEntry.getEOF();
assertEquals(28, tokens.size());
}
@Test
public void testBlockComments() throws IOException {
SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader("%{" + PMD.EOL
+ " Name: helloworld.m\n" + PMD.EOL
+ " Purpose: Say \"Hello World!\" in two different ways" + PMD.EOL
+ "%}" + PMD.EOL
+ PMD.EOL
+ "% Do it the good ol' fashioned way...command window" + PMD.EOL
+ "disp('Hello World!');\n" + PMD.EOL
+ "%" + PMD.EOL
+ "% Do it the new hip GUI way...with a message box" + PMD.EOL
+ "msgbox('Hello World!','Hello World!');"));
Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens); // should not result in parse error
TokenEntry.getEOF();
assertEquals(13, tokens.size());
}
}