@Test
public void testReachableVariablesMatchMatchWithMatchReturn() {

    String cypher = "" +
            "MATCH (a)--(b)\n" +     // match0
            "MATCH (b)\n" +          // match1
            "WITH (a)\n" +           // with2
            "MATCH (b)\n" +          // match3
            "RETURN a.firstName";    // ret
    Statement st = PassAvailables.parseCypher(cypher);
    SingleQuery sq = (SingleQuery) st.query.part;
    VarDependencies dependencies = new VarDependencies(st);
    Iterator<Clause> iter = sq.clauses.iterator();
    AvailableVariables match0 = dependencies.getReachableVars(this.genClauseForASTNode(this.getPatternPart(iter.next()).next()));
    AvailableVariables match1 = dependencies.getReachableVars(this.genClauseForASTNode(this.getPatternPart(iter.next()).next()));
    AvailableVariables with2 = dependencies.getReachableVars(this.genClauseForASTNode(iter.next()));
    AvailableVariables match3 = dependencies.getReachableVars(this.genClauseForASTNode(this.getPatternPart(iter.next()).next()));
    AvailableVariables ret = dependencies.getReachableVars(this.genClauseForASTNode(iter.next()));
    Assert.assertTrue(match0.isEmpty());
    Assert.assertTrue(match1.get("a").isPresent());
    Assert.assertTrue(match1.get("b").isPresent());
    Assert.assertTrue(with2.get("a").isPresent());
    Assert.assertTrue(with2.get("b").isPresent());
    Assert.assertTrue(match3.get("a").isPresent());
    Assert.assertFalse(match3.get("b").isPresent());
    Assert.assertTrue(ret.get("a").isPresent());
    Assert.assertTrue(ret.get("b").isPresent());
}