Exemplo n.º 1
0
 public void testDynamicObjectsRetrival() throws PrologException {
   Prolog engine = new Prolog();
   JavaLibrary lib = (JavaLibrary) engine.getLibrary("alice.tuprolog.lib.JavaLibrary");
   String theory =
       "demo(C) :- \n"
           + "java_object('alice.tuprolog.TestCounter', [], C), \n"
           + "C <- update, \n"
           + "C <- update. \n";
   engine.setTheory(new Theory(theory));
   SolveInfo info = engine.solve("demo(Obj).");
   Struct id = (Struct) info.getVarValue("Obj");
   TestCounter counter = (TestCounter) lib.getRegisteredDynamicObject(id);
   assertEquals(2, counter.getValue());
 }