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");
}
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());
}
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());
}
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());
}
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);
}
Aggregations