Search in sources :

Example 56 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class GetOperationsWithTimeoutTest method testProcessResults.

@Test
public void testProcessResults() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("TO")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar"), new CompoundPrologTerm("bliblablub")));
    GetOperationsWithTimeout command = new GetOperationsWithTimeout("state");
    command.processResult(map);
    List<String> list = command.getTimeouts();
    assertEquals("foobar", list.get(0));
    assertEquals("bliblablub", list.get(1));
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Example 57 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project prob2 by bendisposto.

the class GetOpFromId method processResult.

@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
    ListPrologTerm plist = BindingGenerator.getList(bindings.get(PARAMETERS_VARIABLE));
    params = Collections.emptyList();
    if (!plist.isEmpty()) {
        params = new ArrayList<>();
    }
    for (PrologTerm p : plist) {
        params.add(p.getFunctor().intern());
    }
    ListPrologTerm rlist = BindingGenerator.getList(bindings.get(RETURNVALUES_VARIABLE));
    returnValues = Collections.emptyList();
    if (!rlist.isEmpty()) {
        returnValues = new ArrayList<>();
    }
    for (PrologTerm r : rlist) {
        returnValues.add(r.getFunctor().intern());
    }
    op.setInfo(expansion, params, returnValues);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm)

Example 58 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project probparsers by bendisposto.

the class PrologGeneratorTest method testDET.

@Test
public void testDET() throws Exception {
    final PrologTerm transPred1 = new CompoundPrologTerm("bla");
    final PrologTerm wrapped1 = new CompoundPrologTerm("dtrans", transPred1);
    final PrologTerm transPred2 = new CompoundPrologTerm("argg");
    final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred2);
    final PrologTerm args = new ListPrologTerm(wrapped1, wrapped2);
    final PrologTerm det = new CompoundPrologTerm("det", args);
    final PrologTerm expected = new CompoundPrologTerm("ap", det);
    check("deterministic(bla   , argg)", expected);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 59 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project probparsers by bendisposto.

the class PrologGeneratorTest method testOr.

@Test
public void testOr() throws Exception {
    final PrologTerm expected = new CompoundPrologTerm("or", TERM_TRUE, TERM_FALSE);
    check("true or  false", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 60 with PrologTerm

use of de.prob.prolog.term.PrologTerm in project probparsers by bendisposto.

the class PrologGeneratorTest method testStrongFair_multiple.

@Test
public void testStrongFair_multiple() throws Exception {
    final PrologTerm transPred1 = new CompoundPrologTerm("bla");
    final PrologTerm wrapped1 = new CompoundPrologTerm("dtrans", transPred1);
    final PrologTerm sf1 = new CompoundPrologTerm("strong_fair", wrapped1);
    final PrologTerm ap1 = new CompoundPrologTerm("ap", sf1);
    final PrologTerm transPred2 = new CompoundPrologTerm("blubb");
    final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred2);
    final PrologTerm sf2 = new CompoundPrologTerm("strong_fair", wrapped2);
    final PrologTerm ap2 = new CompoundPrologTerm("ap", sf2);
    final PrologTerm andPred = new CompoundPrologTerm("and", ap1, ap2);
    final PrologTerm strong_assumption = new CompoundPrologTerm("strongassumptions", andPred);
    final PrologTerm expected = new CompoundPrologTerm("fairnessimplication", strong_assumption, TERM_TRUE);
    check("( (sf(bla) & sf(blubb)) => (true))", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Aggregations

PrologTerm (de.prob.prolog.term.PrologTerm)103 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)86 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)85 Test (org.junit.Test)64 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)11 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)10 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)8 Transition (de.prob.statespace.Transition)5 IEvalElement (de.prob.animator.domainobjects.IEvalElement)4 ArrayList (java.util.ArrayList)4 CheckBooleanPropertyCommand (de.prob.animator.command.CheckBooleanPropertyCommand)3 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)3 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)2 LtlParseException (de.be4.ltl.core.parser.LtlParseException)2 ClassicalB (de.prob.animator.domainobjects.ClassicalB)2 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 StateError (de.prob.animator.domainobjects.StateError)2