[ https://issues.apache.org/jira/browse/TINKERPOP-3047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17941995#comment-17941995 ]
ASF GitHub Bot commented on TINKERPOP-3047: ------------------------------------------- Cole-Greer commented on code in PR #3091: URL: https://github.com/apache/tinkerpop/pull/3091#discussion_r2033971474 ########## gremlin-language/src/test/java/org/apache/tinkerpop/gremlin/language/grammar/ReferenceGrammarTest.java: ########## @@ -89,29 +94,73 @@ public class ReferenceGrammarTest extends AbstractGrammarTest { }}; @Parameterized.Parameters(name = "{0}") - public static Iterable<String> queries() throws IOException { - final Set<String> gremlins = new LinkedHashSet<>(DocumentationReader.parse(docsDir)); - gremlins.addAll(FeatureReader.parseGrouped(featureDir, stringMatcherConverters).values().stream().flatMap(Collection::stream).collect(Collectors.toList())); - return gremlins; + public static Iterable<Pair<String, ParserRule>> parseTestItems() throws IOException { + // gremlin scripts from docs + final Set<Pair<String, ParserRule>> scripts = DocumentationReader.parse(docsDir). + stream().map(g -> Pair.with(g, ParserRule.QUERY_LIST)). + collect(Collectors.toCollection(LinkedHashSet::new)); + + // helps make sure we're actually adding test scripts for each load. there are well over 500 gremlin + // examples in the docs so we should have at least that much + int size = scripts.size(); + assert size > 500; + + // gremlin scripts from feature tests + scripts.addAll(FeatureReader.parseGrouped(featureDir, stringMatcherConverters).values().stream(). + flatMap(Collection::stream). + map(g -> Pair.with(g, ParserRule.QUERY_LIST)). + collect(Collectors.toList())); + + // there are well over 1000 tests so make sure we parsed something sensible + assert size < scripts.size() + 1000; + size = scripts.size(); + + // validate that every keyword is parseable as a map key + scripts.addAll(GrammarReader.parse("src/main/antlr4/Gremlin.g4").stream(). + map(g -> Pair.with(String.format("[%s:123]", g), ParserRule.GREMLIN_VALUE)). + collect(Collectors.toList())); + + // there have to be at least 200 tokens parsed from the grammar. just picked a big number to help validate + // that the GrammarReader is doing smart things. + assert size < scripts.size() + 200; Review Comment: ```suggestion assert size +200 < scripts.size(); ``` > Grammar does not parse keywords into Map keys > --------------------------------------------- > > Key: TINKERPOP-3047 > URL: https://issues.apache.org/jira/browse/TINKERPOP-3047 > Project: TinkerPop > Issue Type: Bug > Components: language > Affects Versions: 3.7.1 > Reporter: Stephen Mallette > Priority: Critical > > {{[keys: ["a","b"]}} won't work because "keys" ends up being parsed to > {{Column.keys}}. another issue at play is the use of parens to wrap certain > key definitions but not others. it doesn't feel consistent. like, it will > work for {{T}} values but not for something like "edges" which is just a > keyword token. Not sure it's wrong but it requires some examination. -- This message was sent by Atlassian Jira (v8.20.10#820010)