Search in sources :

Example 46 with CompoundPrologTerm

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

the class StateErrorTest method test.

@Test
public void test() {
    StateError a = new StateError("I", " am", " Awesome.");
    assertEquals("I", a.getEvent());
    assertEquals(" am", a.getShortDescription());
    assertEquals(" Awesome.", a.getLongDescription());
    StateError b = new StateError(new CompoundPrologTerm("cpt", new CompoundPrologTerm("My"), new CompoundPrologTerm(" Life"), new CompoundPrologTerm(" ROCKS!!!")));
    assertEquals("My", b.getEvent());
    assertEquals(" Life", b.getShortDescription());
    assertEquals(" ROCKS!!!", b.getLongDescription());
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) Test(org.junit.Test)

Example 47 with CompoundPrologTerm

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

the class EvaluateFormulasCommandTest method testWriteCommand.

@Test
public void testWriteCommand() throws Exception {
    IEvalElement element = new ClassicalB("1<3", FormulaExpand.EXPAND);
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    EvaluateFormulaCommand command = new EvaluateFormulaCommand(element, "root");
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm t = sentences.iterator().next();
    assertNotNull(t);
    assertTrue(t instanceof CompoundPrologTerm);
    assertEquals("evaluate_formula", t.getFunctor());
    assertEquals(3, t.getArity());
    PrologTerm t1 = t.getArgument(1);
    assertEquals("root", t1.getFunctor());
    PrologTerm t2 = t.getArgument(2);
    assertEquals("eval", t2.getFunctor());
    PrologTerm t3 = t.getArgument(3);
    assertEquals("Res", t3.getFunctor());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) IEvalElement(de.prob.animator.domainobjects.IEvalElement) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ClassicalB(de.prob.animator.domainobjects.ClassicalB) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 48 with CompoundPrologTerm

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

the class EvaluateFormulasCommandTest method testProcessResult.

@Test
public void testProcessResult() throws Exception {
    IEvalElement element = new ClassicalB("1<3", FormulaExpand.EXPAND);
    final CompoundPrologTerm lpt = mk_result("true");
    ISimplifiedROMap<String, PrologTerm> m1 = new ISimplifiedROMap<String, PrologTerm>() {

        @Override
        public PrologTerm get(final String key) {
            return lpt;
        }
    };
    EvaluateFormulaCommand command = new EvaluateFormulaCommand(element, "root");
    command.processResult(m1);
    AbstractEvalResult value = command.getValue();
    assertEquals(((EvalResult) value).getValue(), "true");
    assertEquals(((EvalResult) value).getSolutions().get("a"), "3");
}
Also used : EvalResult(de.prob.animator.domainobjects.EvalResult) AbstractEvalResult(de.prob.animator.domainobjects.AbstractEvalResult) AbstractEvalResult(de.prob.animator.domainobjects.AbstractEvalResult) IEvalElement(de.prob.animator.domainobjects.IEvalElement) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ClassicalB(de.prob.animator.domainobjects.ClassicalB) ISimplifiedROMap(de.prob.parser.ISimplifiedROMap) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 49 with CompoundPrologTerm

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

the class GetOperationsWithTimeoutTest method testErrorProcessResults.

@Test(expected = ResultParserException.class)
public void testErrorProcessResults() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get(anyString())).thenReturn(new CompoundPrologTerm("bang!!!"));
    GetOperationsWithTimeout command = new GetOperationsWithTimeout("state");
    command.processResult(map);
}
Also used : 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 50 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm 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)

Aggregations

CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)90 PrologTerm (de.prob.prolog.term.PrologTerm)79 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)74 Test (org.junit.Test)62 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)8 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)7 ClassicalB (de.prob.animator.domainobjects.ClassicalB)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)6 EventB (de.prob.animator.domainobjects.EventB)5 Transition (de.prob.statespace.Transition)5 ArrayList (java.util.ArrayList)4 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 IEvalElement (de.prob.animator.domainobjects.IEvalElement)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)2 BigInteger (java.math.BigInteger)2 Collections (java.util.Collections)2 BParser (de.be4.classicalb.core.parser.BParser)1