post queries: refactor AST #simplify method.
Refactor the `PostQuery::AST#simplify` method to split it into three methods: `#trim` to eliminate redundant AND and OR clauses, `#simplify` to expand deeply nested subexpressions, and `#sort` to sort the query into alphabetical order. This is so we can normalize queries written by users by parsing and rewriting them, but without expanding out nested subexpressions, which can substantially alter the way the query is written.
This commit is contained in:
@@ -2,7 +2,7 @@ require 'test_helper'
|
||||
|
||||
class PostQueryParserTest < ActiveSupport::TestCase
|
||||
def assert_parse_equals(expected, input)
|
||||
assert_equal(expected, PostQuery::Parser.parse(input).simplify.to_sexp)
|
||||
assert_equal(expected, PostQuery::Parser.parse(input).to_cnf.to_sexp)
|
||||
end
|
||||
|
||||
def to_infix(string)
|
||||
|
||||
Reference in New Issue
Block a user