Skip to content

Commit 130164c

Browse files
committed
Fix negation operators on arrays to use correct quantifier
For negation operators (IS_NOT, DOES_NOT_CONTAIN, REGEX_DOES_NOT_MATCH), the match_string method already negates internally. Using any? produced 'at least one element doesn't match' semantics, causing arrays like ['A', 'B'] to match both IS 'A' and IS_NOT 'A' simultaneously. Changed to use all? for negation operators, ensuring 'all elements satisfy the negation' (i.e., no element matches the positive condition).
1 parent c9f7cb1 commit 130164c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lib/experiment/evaluation/evaluation.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,20 @@ def match_condition(target, condition)
8282
end
8383

8484
def match_strings_non_set(prop_values, op, filter_values)
85-
prop_values.any? { |v| match_string(v, op, filter_values) }
85+
if negation_operator?(op)
86+
prop_values.all? { |v| match_string(v, op, filter_values) }
87+
else
88+
prop_values.any? { |v| match_string(v, op, filter_values) }
89+
end
90+
end
91+
92+
def negation_operator?(op)
93+
case op
94+
when Operator::IS_NOT, Operator::DOES_NOT_CONTAIN, Operator::REGEX_DOES_NOT_MATCH
95+
true
96+
else
97+
false
98+
end
8699
end
87100

88101
def get_hash(key)

0 commit comments

Comments
 (0)