textquery
textquery copied to clipboard
Tests say AND should have precedence over OR, test doesn't test it, code doesn't do it.
Multiple things wrong here:
-
The code uses simple left-to-right precedence, it doesn't favour either AND or OR: https://github.com/igrigorik/textquery/blob/master/lib/textquery/textquery_grammar.treetop#L8
-
The comment in the test shows OR having greater precedence, contrary to the meaning of "precedence" (binds tighter) and to the established principle from maths and logic. AND is the logical analog of multiplication, OR of addition, so the precedence in other systems always nests brackets around AND groups in preference to OR, like in mathematics. See <https://github.com/igrigorik/textquery/blob/master/spec/textquery_spec.rb#L52
-
The test doesn't actually test for AND taking precedence in any case. https://github.com/igrigorik/textquery/blob/master/spec/textquery_spec.rb#L51-60
A patch is forthcoming on my branch.