Search in sources :

Example 96 with PrologTerm

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

the class LoadBProjectCommandTest method testWriteCommand.

@Test
public void testWriteCommand() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    URL resource = classLoader.getResource("examples/scheduler.mch");
    File f = new File(resource.toURI());
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    ClassicalBFactory factory = new ClassicalBFactory(null);
    BParser bparser = new BParser();
    Start ast = factory.parseFile(f, bparser);
    RecursiveMachineLoader rml = factory.parseAllMachines(ast, f.getParent(), f, bparser.getContentProvider(), bparser);
    LoadBProjectCommand command = new LoadBProjectCommand(rml, f);
    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("load_classical_b_from_list_of_facts", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument = t.getArgument(2);
    assertTrue(argument.isList());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) ClassicalBFactory(de.prob.scripting.ClassicalBFactory) Start(de.be4.classicalb.core.parser.node.Start) BParser(de.be4.classicalb.core.parser.BParser) RecursiveMachineLoader(de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) File(java.io.File) URL(java.net.URL) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 97 with PrologTerm

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

the class GetStateBasedErrorsCommandTest method testErrorProcessResult2.

@Test(expected = ResultParserException.class)
public void testErrorProcessResult2() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("Errors")).thenReturn(new CompoundPrologTerm("foobar"));
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("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 98 with PrologTerm

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

the class GetStateBasedErrorsCommandTest method testErrorProcessResult1.

@Test(expected = ResultParserException.class)
public void testErrorProcessResult1() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get("Errors")).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar")));
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("state");
    command.processResult(map);
}
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)

Example 99 with PrologTerm

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

the class GetErrorsCommandTest method testProcessResults.

@Test
public void testProcessResults() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get(anyString())).thenReturn(new ListPrologTerm(new CompoundPrologTerm("foobar")));
    GetErrorsCommand command = new GetErrorsCommand();
    command.processResult(map);
    List<String> errors = command.getErrors();
    assertEquals("foobar", errors.get(0));
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) Matchers.anyString(org.mockito.Matchers.anyString) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 100 with PrologTerm

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

the class GetPreferencesCommandTest method testProcessResultsFail.

@Test(expected = ResultParserException.class)
public void testProcessResultsFail() {
    @SuppressWarnings("unchecked") ISimplifiedROMap<String, PrologTerm> map = mock(ISimplifiedROMap.class);
    when(map.get(anyString())).thenReturn(new ListPrologTerm(new CompoundPrologTerm("blah blah blah")));
    GetDefaultPreferencesCommand command = new GetDefaultPreferencesCommand();
    command.processResult(map);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) 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