Compare commits

...

1 Commits

Author SHA1 Message Date
Patrick Stevens
d1dde56d06 Fix filter bug (#322) 2025-11-10 19:31:33 +00:00
2 changed files with 15 additions and 2 deletions

View File

@@ -108,7 +108,8 @@ module internal Lexer =
i <- i + 1
| _ ->
yield Token.single TokenType.Not startI 1
i <- i + 1
// Don't advance i here - we only consumed the '!' character
()
| Token.SingleChar token, State.Awaiting ->
i <- i + 1
yield token
@@ -162,7 +163,7 @@ module internal ParsedFilter =
match token.Type with
| TokenType.QuotedString ->
// +1 and -1, because the trivia contains the initial and terminal quote mark
// +1 to skip the initial quote; len includes the initial quote but excludes the terminal quote
inputString.Substring (start + 1, len - 1)
|> unescape
|> ParsedFilter.String

View File

@@ -123,3 +123,15 @@ module TestFilter =
[<TestCaseSource(nameof xmlExamples)>]
let ``XML examples`` (example : string, expected : Filter) =
Filter.parse example |> shouldEqual expected
let negationExamples =
[
"!Name=foo", Filter.Not (Filter.Name (Match.Exact "foo"))
"!FullyQualifiedName=bar", Filter.Not (Filter.FullyQualifiedName (Match.Exact "bar"))
"!TestCategory=baz", Filter.Not (Filter.TestCategory (Match.Exact "baz"))
]
|> List.map TestCaseData
[<TestCaseSource(nameof negationExamples)>]
let ``Negation examples`` (example : string, expected : Filter) =
Filter.parse example |> shouldEqual expected