// Path: src/main/java/org/dice/parsing/ast/Expression.java
// public interface Expression {
// 	public String evaluate();
// }


import org.dice.parsing.ast.Expression;
import org.junit.Test;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.assertEquals;
        assertEquals("(java AND sql)", parseWithoutErrors("java and sql"));
        assertEquals("(java AND sql)", parseWithoutErrors("java aNd sql"));
        assertEquals("(java AND sql)", parseWithoutErrors("java AND sql"));

        assertEquals("(java OR sql)", parseWithoutErrors("java or sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java oR sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java Or sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java OR sql"));
    }

    @Test
    public void enforcesOperatorPrecedence(){
        assertEquals("((java AND sql) OR ruby)", parseWithoutErrors("java and sql or ruby"));
        assertEquals("(java OR (sql AND ruby))", parseWithoutErrors("java or sql AnD ruby"));
    }

    @Test
    // Note that solr always parses NOT correctly as it's a unary operator (and the reasons for the
    // issues with boolean operator precedence resolve around converting boolean to unary operators
    public void parsesNotOperator(){
        // Note - see comments above
        assertEquals("NOT java", parseWithoutErrors("not java"));
        assertEquals("(NOT java AND sql)", parseWithoutErrors("not java and sql"));
        assertEquals("((NOT java AND sql) OR ruby)", parseWithoutErrors("not java and sql or ruby"));
        assertEquals("(NOT (java AND sql) OR ruby)", parseWithoutErrors("not (java and sql) or ruby"));

    }

    private String parseWithoutErrors(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
// Path: src/main/java/org/dice/parsing/ast/Expression.java
// public interface Expression {
// 	public String evaluate();
// }


// Path: src/test/java/org/dice/parsing/TestRecursiveDescentParser.java
import org.dice.parsing.ast.Expression;
import org.junit.Test;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static junit.framework.TestCase.assertEquals;

        assertEquals("(java AND sql)", parseWithoutErrors("java and sql"));
        assertEquals("(java AND sql)", parseWithoutErrors("java aNd sql"));
        assertEquals("(java AND sql)", parseWithoutErrors("java AND sql"));

        assertEquals("(java OR sql)", parseWithoutErrors("java or sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java oR sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java Or sql"));
        assertEquals("(java OR sql)", parseWithoutErrors("java OR sql"));
    }

    @Test
    public void enforcesOperatorPrecedence(){
        assertEquals("((java AND sql) OR ruby)", parseWithoutErrors("java and sql or ruby"));
        assertEquals("(java OR (sql AND ruby))", parseWithoutErrors("java or sql AnD ruby"));
    }

    @Test
    // Note that solr always parses NOT correctly as it's a unary operator (and the reasons for the
    // issues with boolean operator precedence resolve around converting boolean to unary operators
    public void parsesNotOperator(){
        // Note - see comments above
        assertEquals("NOT java", parseWithoutErrors("not java"));
        assertEquals("(NOT java AND sql)", parseWithoutErrors("not java and sql"));
        assertEquals("((NOT java AND sql) OR ruby)", parseWithoutErrors("not java and sql or ruby"));
        assertEquals("(NOT (java AND sql) OR ruby)", parseWithoutErrors("not (java and sql) or ruby"));

    }

    private String parseWithoutErrors(String input){
        RecursiveDescentParser parser = new RecursiveDescentParser(new Lexer(input), WILDCARD_TOKEN);
        final Expression ast = parser.parse();