When there is a cyclic chain of variable assignments (e.g. X assigned to Y, Y assigned to Z, Z assigned to X) then the Variable.getValue() never terminates.
Example of how to observe this bug using Prolog:
?- p(A,B,C,D,E,F)=p(E,A,D,F,C,B), numbervars(A).
JUnit tests that demonstrates this bug:
@Test
public void test() {
Variable v = new Variable("V");
Variable w = new Variable("W");
Variable x = new Variable("X");
Variable y = new Variable("Y");
Variable z = new Variable("Z");
v.unify(w);
w.unify(x);
x.unify(y);
y.unify(z);
z.unify(x);
// v.getTerm() will never terminate
assertSame(z, v.getTerm());
}
When there is a cyclic chain of variable assignments (e.g.
X
assigned toY
,Y
assigned toZ
,Z
assigned toX
) then theVariable.getValue()
never terminates.Example of how to observe this bug using Prolog:
JUnit tests that demonstrates this bug: