Skip to content

Commit

Permalink
Tentative fix for some cases where stage reordering borks comparators…
Browse files Browse the repository at this point in the history
… and logicalops
  • Loading branch information
Knetic committed Oct 11, 2016
1 parent 583582e commit 8435889
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
48 changes: 48 additions & 0 deletions evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,54 @@ func TestParameterizedEvaluation(test *testing.T) {
},
Expected: 1.0,
},
EvaluationTest{

Name: "Multiple comparator/logical operators (#30)",
Input: "(foo >= 2887057408 && foo <= 2887122943) || (foo >= 168100864 && foo <= 168118271)",
Parameters: []EvaluationParameter{
EvaluationParameter{
Name: "foo",
Value: 2887057409,
},
},
Expected: true,
},
EvaluationTest{

Name: "Multiple comparator/logical operators, opposite order (#30)",
Input: "(foo >= 168100864 && foo <= 168118271) || (foo >= 2887057408 && foo <= 2887122943)",
Parameters: []EvaluationParameter{
EvaluationParameter{
Name: "foo",
Value: 2887057409,
},
},
Expected: true,
},
EvaluationTest{

Name: "Multiple comparator/logical operators, small value (#30)",
Input: "(foo >= 2887057408 && foo <= 2887122943) || (foo >= 168100864 && foo <= 168118271)",
Parameters: []EvaluationParameter{
EvaluationParameter{
Name: "foo",
Value: 168100865,
},
},
Expected: true,
},
EvaluationTest{

Name: "Multiple comparator/logical operators, small value, opposite order (#30)",
Input: "(foo >= 168100864 && foo <= 168118271) || (foo >= 2887057408 && foo <= 2887122943)",
Parameters: []EvaluationParameter{
EvaluationParameter{
Name: "foo",
Value: 168100865,
},
},
Expected: true,
},
EvaluationTest{

Name: "Mixed function and parameters",
Expand Down
4 changes: 4 additions & 0 deletions stagePlanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ func reorderStages(rootStage *evaluationStage) {

currentPrecedence = findOperatorPrecedenceForSymbol(currentStage.symbol)

if currentPrecedence == COMPARATOR_PRECEDENCE || currentPrecedence == LOGICAL_PRECEDENCE {
continue
}

if currentPrecedence == precedence {
identicalPrecedences = append(identicalPrecedences, currentStage)
continue
Expand Down

0 comments on commit 8435889

Please sign in to comment.