Search in sources :

Example 46 with PrologTerm

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

the class GetStateBasedErrorsCommandTest method testProcessResultEmpty.

@Test
public void testProcessResultEmpty() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("Errors")).thenReturn(new ListPrologTerm());
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
    command.processResult(map);
    Collection<StateError> coll = command.getResult();
    assertEquals(Collections.emptyList(), coll);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) StateError(de.prob.animator.domainobjects.StateError) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Example 47 with PrologTerm

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

the class SetPreferenceCommandTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    SetPreferenceCommand command = new SetPreferenceCommand("foo", "bar");
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm t = sentences.iterator().next();
    assertNotNull(t);
    assertTrue(t instanceof CompoundPrologTerm);
    assertEquals("set_eclipse_preference", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument1 = t.getArgument(1);
    assertTrue(argument1.isAtom());
    assertEquals(argument1.toString(), "foo");
    PrologTerm argument2 = t.getArgument(2);
    assertTrue(argument2.isAtom());
    assertEquals(argument2.toString(), "bar");
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 48 with PrologTerm

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

the class GetErrorsCommandTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    GetErrorsCommand command = new GetErrorsCommand();
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm next = sentences.iterator().next();
    assertNotNull(next);
    assertTrue(next instanceof CompoundPrologTerm);
    CompoundPrologTerm t = (CompoundPrologTerm) next;
    assertEquals("get_error_messages", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument = t.getArgument(1);
    assertTrue(argument.isVariable());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) 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 49 with PrologTerm

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

the class GetPreferencesCommandTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm t = sentences.iterator().next();
    assertNotNull(t);
    assertTrue(t instanceof CompoundPrologTerm);
    assertEquals("list_all_eclipse_preferences", t.getFunctor());
    assertEquals(1, t.getArity());
    PrologTerm argument = t.getArgument(1);
    assertTrue(argument.isVariable());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) 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 50 with PrologTerm

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

the class GetPreferencesCommandTest method testProcessResults.

@Test
public void testProcessResults() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("Prefs")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("preference", new CompoundPrologTerm("tinker"), new CompoundPrologTerm("tailor"), new CompoundPrologTerm("soldier"), new CompoundPrologTerm("sailor"), new CompoundPrologTerm("foo")), new CompoundPrologTerm("preference", new CompoundPrologTerm("richman"), new CompoundPrologTerm("poorman"), new CompoundPrologTerm("beggarman"), new CompoundPrologTerm("thief"), new CompoundPrologTerm("bar"))));
    GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
    command.processResult(map);
    List<ProBPreference> prefs = command.getPreferences();
    assertEquals(prefs.size(), 2);
    ProBPreference pref1 = prefs.get(0);
    assertEquals(pref1.name, "tinker");
    assertEquals(pref1.type.toString(), "tailor");
    assertEquals(pref1.description, "soldier");
    assertEquals(pref1.category, "sailor");
    assertEquals(pref1.defaultValue, "foo");
    ProBPreference pref2 = prefs.get(1);
    assertEquals(pref2.name, "richman");
    assertEquals(pref2.type.toString(), "poorman");
    assertEquals(pref2.description, "beggarman");
    assertEquals(pref2.category, "thief");
    assertEquals(pref2.defaultValue, "bar");
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) ProBPreference(de.prob.animator.domainobjects.ProBPreference) 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