diff --git a/src/main/antlr4/com/pdsl/gherkin/filter/GherkinTags.g4 b/src/main/antlr4/com/pdsl/gherkin/filter/GherkinTags.g4 index 3af5bea..1d6e7ca 100644 --- a/src/main/antlr4/com/pdsl/gherkin/filter/GherkinTags.g4 +++ b/src/main/antlr4/com/pdsl/gherkin/filter/GherkinTags.g4 @@ -9,7 +9,7 @@ fragment T : 'T' | 't'; fragment R : 'R' | 'r'; -TAG :'@' ~[@ )]+ ; +TAG :'@' ~[@ ()]+ ('(' ~[)]* ')')? ; WS : [ \t]+ -> skip; AND : A N D ; OR : O R; diff --git a/src/test/java/com/pdsl/unit/GherkinTagFiltererTest.java b/src/test/java/com/pdsl/unit/GherkinTagFiltererTest.java index ced49fc..3fc5be7 100644 --- a/src/test/java/com/pdsl/unit/GherkinTagFiltererTest.java +++ b/src/test/java/com/pdsl/unit/GherkinTagFiltererTest.java @@ -30,6 +30,27 @@ public void filterTagWithSpecialCharacterPositive_keepPickle() { assertThat(filter.tagExpressionMatchesPickle(tags, "@!@#$")).isTrue(); } + @Test + public void filterTagWithParenthesizedUuidValue_keepPickle() { + Set uuidTags = Set.of("@id(\"550e8400-e29b-41d4-a716-446655440000\")"); + assertThat(filter.tagExpressionMatchesPickle(uuidTags, + "@id(\"550e8400-e29b-41d4-a716-446655440000\")")).isTrue(); + } + + @Test + public void filterTagWithParenthesizedValue_andExpression_keepPickle() { + Set uuidTags = Set.of("@id(\"550e8400-e29b-41d4-a716-446655440000\")", "@tagB"); + assertThat(filter.tagExpressionMatchesPickle(uuidTags, + "@id(\"550e8400-e29b-41d4-a716-446655440000\") and @tagB")).isTrue(); + } + + @Test + public void filterTagWithParenthesizedValue_mismatchedUuid_removePickle() { + Set uuidTags = Set.of("@id(\"550e8400-e29b-41d4-a716-446655440000\")"); + assertThat(filter.tagExpressionMatchesPickle(uuidTags, + "@id(\"00000000-0000-0000-0000-000000000000\")")).isFalse(); + } + @Test public void filterTagNotExpression_keepPickle() { assertThat(filter.tagExpressionMatchesPickle(tags, "not @tagMissing")).isTrue();