package io.cucumber.tagexpressions;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

public class TagExpressionParserTest {
    @Rule
    public ExpectedException exception = ExpectedException.none();

    private TagExpressionParser parser = new TagExpressionParser();

    @Test
    public void evaluates_not() {
        Expression expr = parser.parse("not   x");
        assertEquals(false, expr.evaluate(singletonList("x")));
        assertEquals(true, expr.evaluate(singletonList("y")));
    }

    @Test
    public void evaluates_example() {
        Expression expr = parser.parse("not @a or @b and not @c or not @d or @e and @f");
        assertFalse(expr.evaluate(asList("@a @c @d".split(" "))));
    }

    @Test
    public void errors_when_there_are_only_operators() {
        exception.expect(TagExpressionException.class);
        parser.parse("or or");
    }
}

@@ -297,16 +297,59 @@
 rtFalse;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Apublic
@@ -961,32 +961,390 @@
 %22 %22))));%0A    %7D%0A%0A
+    @Test%0A    public void evaluates_expr_with_escaped_chars() %7B%0A        Expression expr = parser.parse(%22((not @a%5C%5C(1%5C%5C) or @b%5C%5C(2%5C%5C)) and not @c%5C%5C(3%5C%5C) or not @d%5C%5C(4%5C%5C) or @e%5C%5C(5%5C%5C) and @f%5C%5C(6%5C%5C))%22);%0A        assertFalse(expr.evaluate(asList(%22@a(1) @c(3) @d(4)%22.split(%22 %22))));%0A        assertTrue(expr.evaluate(asList(%22@b(2) @e(5) @f(6)%22.split(%22 %22))));%0A    %7D%0A%0A
     @Test%0A    pu

add test case