Search in sources :

Example 6 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput 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 7 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput 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 8 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput 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 9 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput 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 10 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project probparsers by bendisposto.

the class ProBParserBaseAdapter method parseTransitionPredicate.

public PrologTerm parseTransitionPredicate(final String transPredicate, final boolean wrap) throws ProBParseException, UnsupportedOperationException {
    final StructuredPrologOutput pto = new StructuredPrologOutput();
    base.parseTransitionPredicate(pto, transPredicate, wrap);
    return getSingleTerm(pto);
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput)

Aggregations

StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)14 PrologTerm (de.prob.prolog.term.PrologTerm)10 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)7 Test (org.junit.Test)7 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)5 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)2 BParser (de.be4.classicalb.core.parser.BParser)1 Start (de.be4.classicalb.core.parser.node.Start)1 LtlAdapterException (de.be4.ltl.core.parser.internal.LtlAdapterException)1 ClassicalB (de.prob.animator.domainobjects.ClassicalB)1 IEvalElement (de.prob.animator.domainobjects.IEvalElement)1 ClassicalBFactory (de.prob.scripting.ClassicalBFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1