Skip to content

Commit 94bbadc

Browse files
test: add tests for upgraded JavaCC (manticore branch)
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 4f11c2f commit 94bbadc

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎src/test/java/net/sf/jsqlparser/parser/CCJSqlParserTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
package net.sf.jsqlparser.parser;
1111

1212
import static org.assertj.core.api.Assertions.assertThat;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
1314

15+
import net.sf.jsqlparser.JSQLParserException;
1416
import org.junit.jupiter.api.Test;
1517

1618
import net.sf.jsqlparser.parser.feature.Feature;
19+
import org.junit.jupiter.params.ParameterizedTest;
20+
import org.junit.jupiter.params.provider.CsvSource;
1721

1822
public class CCJSqlParserTest {
1923
@Test
@@ -24,4 +28,21 @@ public void parserWithTimeout() throws Exception {
2428

2529
assertThat(timeOut).isEqualTo(123L);
2630
}
31+
32+
@ParameterizedTest
33+
@CsvSource(delimiter = '|', value = {
34+
"SELECT /* c */1 | SELECT /* c */ 1",
35+
"SELECT 1 /* c */+2 | SELECT 1 /* c */ +2",
36+
"SELECT 1/*x*/+2 | SELECT 1 /*x*/ +2",
37+
"SELECT /* a /* b */ c */1 | SELECT /* a /* b */ c */ 1",
38+
"SELECT * FROM t WHERE/*c*/x=1 | SELECT * FROM t WHERE /*c*/ x=1",
39+
"SELECT/*+ FULL(t) */*FROM t | SELECT /*+ FULL(t) */ * FROM t"
40+
})
41+
void testBlockCommentFollowedByNonWhitespace(String tight, String spaced)
42+
throws JSQLParserException {
43+
// Issue #2509: the first character after */ was swallowed into the comment token,
44+
// so the tight form either failed to parse or silently lost that character.
45+
assertEquals(CCJSqlParserUtil.parse(spaced).toString(),
46+
CCJSqlParserUtil.parse(tight).toString());
47+
}
2748
}

‎src/test/java/net/sf/jsqlparser/statement/select/SelectASTTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public Object visit(Node node, Object data) {
200200
}
201201
}, null);
202202

203-
assertThat(comments).extracting(token -> token.image).containsExactly("/* testcomment */ ",
203+
assertThat(comments).extracting(token -> token.image).containsExactly("/* testcomment */",
204204
"-- testcomment2 ");
205205
}
206206

@@ -211,7 +211,7 @@ public void testSelectASTExtractWithCommentsIssue1580_2() throws JSQLParserExcep
211211
Node root = (Node) CCJSqlParserUtil.parseAST(sql);
212212

213213
assertThat(root.jjtGetFirstToken().specialToken.image)
214-
.isEqualTo("/* I want this comment */\n");
214+
.isEqualTo("/* I want this comment */");
215215
}
216216

217217
@Test

0 commit comments

Comments
 (0)