Search in sources :

Example 41 with CompoundPrologTerm

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

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

the class ProBPreferenceTest method test.

@Test
public void test() {
    VariablePrologTerm typeAwesome = new VariablePrologTerm("TypeAwesome");
    CompoundPrologTerm cpt = new CompoundPrologTerm("cpt", new CompoundPrologTerm("IamAwesome"), typeAwesome, new CompoundPrologTerm("descriptionAwesome"), new CompoundPrologTerm("categoryAwesome"), new CompoundPrologTerm("awesomeDefaultValue"));
    ProBPreference a = new ProBPreference(cpt);
    assertEquals("IamAwesome", a.name);
    assertEquals(typeAwesome, a.type);
    assertEquals("descriptionAwesome", a.description);
    assertEquals("categoryAwesome", a.category);
    assertEquals("awesomeDefaultValue", a.defaultValue);
    assertEquals("IamAwesome(cat. categoryAwesome, type TypeAwesome, default awesomeDefaultValue) descriptionAwesome", a.toString());
    CompoundPrologTerm cpt2 = new CompoundPrologTerm("cpt", new CompoundPrologTerm("IamAwesome"), typeAwesome, new CompoundPrologTerm("descriptionAwesome"), new CompoundPrologTerm("categoryAwesome"), new CompoundPrologTerm("awesomeDefaultValue", new CompoundPrologTerm("I"), new CompoundPrologTerm(" am"), new CompoundPrologTerm(" not"), new CompoundPrologTerm(" simple.")));
    a = new ProBPreference(cpt2);
    assertEquals("IamAwesome", a.name);
    assertEquals(typeAwesome, a.type);
    assertEquals("descriptionAwesome", a.description);
    assertEquals("categoryAwesome", a.category);
    assertEquals("awesomeDefaultValue('I',' am',' not',' simple.')", a.defaultValue);
}
Also used : VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) Test(org.junit.Test)

Example 43 with CompoundPrologTerm

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

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

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

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