Node_RuleVariable xh = new Node_RuleVariable("?x", 0);
Node_RuleVariable yh = new Node_RuleVariable("?y", 1);
Node_RuleVariable zh = new Node_RuleVariable("?z", 2);
TriplePattern g1 = new TriplePattern(xg, p, yg);
TriplePattern g2 = new TriplePattern(xg, p, xg);
TriplePattern g3 = new TriplePattern( a, p, xg);
TriplePattern g4 = new TriplePattern( a, p, b);
TriplePattern h1 = new TriplePattern(xh, p, yh);
TriplePattern h2 = new TriplePattern(xh, p, xh);
TriplePattern h3 = new TriplePattern( a, p, xh);
TriplePattern h4 = new TriplePattern( a, p, b);
TriplePattern h5 = new TriplePattern(xh, p, a);
doTestUnify(g1, h1, true, new Node[] {null, null});
doTestUnify(g1, h2, true, new Node[] {null, null});
doTestUnify(g1, h3, true, new Node[] {null, null});
doTestUnify(g1, h4, true, new Node[] {null, null});
doTestUnify(g1, h5, true, new Node[] {null, null});
doTestUnify(g2, h1, true, new Node[] {null, xh});
doTestUnify(g2, h2, true, new Node[] {null, null});
doTestUnify(g2, h3, true, new Node[] {a, null});
doTestUnify(g2, h4, false, null);
doTestUnify(g2, h5, true, new Node[] {a, null});
doTestUnify(g3, h1, true, new Node[] {a, null});
doTestUnify(g3, h2, true, new Node[] {a, null});
doTestUnify(g3, h3, true, new Node[] {null, null});
doTestUnify(g3, h4, true, new Node[] {null, null});
doTestUnify(g3, h5, true, new Node[] {a, null});
doTestUnify(g4, h1, true, new Node[] {a, b});
doTestUnify(g4, h2, false, null);
doTestUnify(g4, h3, true, new Node[] {b});
doTestUnify(g4, h4, true, null);
doTestUnify(g4, h5, false, null);
// Recursive case
doTestUnify(h1, h1, true, new Node[] {null, null});
// Wildcard case
doTestUnify(new TriplePattern(null, null, null), h2, true, new Node[] {null, null});
// Test functor cases as well!
TriplePattern gf = new TriplePattern(xg, p,
Functor.makeFunctorNode("f", new Node[]{xg, b}));
TriplePattern hf1 = new TriplePattern(yh, p,
Functor.makeFunctorNode("f", new Node[]{zh, b}));
TriplePattern hf2 = new TriplePattern(yh, p,
Functor.makeFunctorNode("f", new Node[]{a, yh}));
TriplePattern hf3 = new TriplePattern(yh, p,
Functor.makeFunctorNode("f", new Node[]{b, yh}));
doTestUnify(gf, hf1, true, new Node[] {null, null, yh});
doTestUnify(gf, hf2, false, null);
doTestUnify(gf, hf3, true, new Node[] {null, b});