fix(advanced-search): D — correct @/| operator precedence (OR binds looser than AND)
Extracts a pure, testable AdvancedSearchUtilities.EvaluateBoolean that splits on the outermost '|' (OR) before '@' (AND), so `a@b|c` now evaluates as `(a&&b)||c` instead of the previous `a&&(b||c)`. AdvancedSearchThreadWorker.EvaluateRecursive delegates to it, supplying the entity-aware leaf evaluator.
This commit is contained in:
parent
8aa797a586
commit
ed5e8d243f
3 changed files with 35 additions and 18 deletions
|
|
@ -39,4 +39,19 @@ public class AdvancedSearchUtilitiesTests
|
|||
{
|
||||
Assert.True(AdvancedSearchUtilities.CompareValues(typeof(Layer), (byte)Layer.OneHanded, "onehanded", "="));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// leaf value is "T"/"F"; evalLeaf returns leaf=="T"
|
||||
[InlineData("T", true)]
|
||||
[InlineData("F", false)]
|
||||
[InlineData("F@F|T", true)] // (F&&F)||T = T (buggy code gave F&&(F||T)=F)
|
||||
[InlineData("T|F@F", true)] // T||(F&&F) = T (buggy code gave (T||F)&&F=F)
|
||||
[InlineData("T@F", false)]
|
||||
[InlineData("T@T", true)]
|
||||
[InlineData("F|F", false)]
|
||||
public void EvaluateBoolean_Precedence(string expr, bool expected)
|
||||
{
|
||||
var result = AdvancedSearchUtilities.EvaluateBoolean(expr, leaf => leaf == "T");
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue