use of com.sri.ai.grinder.theory.tuple.rewriter.TupleGetSimplifier in project aic-expresso by aic-sri-international.
the class TupleRewriterTest method testTupleGetSimplification.
@Test
public void testTupleGetSimplification() {
Simplifier tupleGetSimplifier = new TupleGetSimplifier();
Assert.assertEquals(parse("a"), tupleGetSimplifier.apply(parse("get((a,b,c),1)"), context));
Assert.assertEquals(parse("b"), tupleGetSimplifier.apply(parse("get((a,b,c),2)"), context));
Assert.assertEquals(parse("c"), tupleGetSimplifier.apply(parse("get((a,b,c),3)"), context));
Assert.assertEquals(parse("a"), tupleGetSimplifier.apply(parse("get(tuple(a),I)"), context));
Assert.assertEquals(parse("if I = 1 then a else b"), tupleGetSimplifier.apply(parse("get((a,b),I)"), context));
Assert.assertEquals(parse("if I = 1 then a else if I = 2 then b else c"), tupleGetSimplifier.apply(parse("get((a,b,c),I)"), context));
Expression expr = parse("get(I, (a,b,c))");
Assert.assertTrue(expr == tupleGetSimplifier.apply(expr, context));
expr = parse("get(N, 1)");
Assert.assertTrue(expr == tupleGetSimplifier.apply(expr, context));
}
Aggregations