use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class FlowOptimizer_ExecutionEntryTest method testNoNullCall.
@Test
public void testNoNullCall() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
State s2 = _createState("s2", r);
{
_createEntryAssignment(v1, s2, 3);
Region r2 = _createRegion("r2", s2);
{
Entry e = _createEntry(EntryKind.INITIAL, null, r2);
Entry history = _createEntry(EntryKind.SHALLOW_HISTORY, "history", r2);
State s3 = _createState("s3", r2);
{
_createEntryAssignment(v1, s3, 4);
}
State s4 = _createState("s4", r2);
{
Region r4 = _createRegion("r4", s4);
{
Entry e4 = _createEntry(EntryKind.INITIAL, null, r2);
State s5 = _createState("s5", r4);
_createTransition(e4, s5);
_createTransition(s5, s1);
}
}
_createTransition(e, s3);
_createTransition(history, s3);
_createTransition(s3, s4);
_createTransition(s1, history);
}
}
_createTransition(r_entry, s1);
_createTransition(s1, s2);
}
}
ExecutionFlow flow = sequencer.transform(sc);
optimizer.inlineChoices(true);
optimizer.inlineEnterSequences(true);
optimizer.inlineEntryActions(true);
optimizer.inlineExitActions(true);
optimizer.inlineExitRegion(true);
optimizer.inlineExitSequences(true);
optimizer.inlineReactions(true);
optimizer.inlineEntries(true);
optimizer.transform(flow);
TreeIterator<EObject> iter = flow.eAllContents();
while (iter.hasNext()) {
EObject child = iter.next();
if (child instanceof Call) {
Call childCall = (Call) child;
if (childCall.getStep() == null) {
if (childCall.eContainer() instanceof Sequence) {
Sequence sequence = (Sequence) childCall.eContainer();
fail(sequence.getName() + ": " + sequence.getComment());
} else {
fail("Call of null-Step in " + childCall.eContainer());
}
}
}
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class STextJavaValidatorTest method checkValueDefinitionExpression.
@Test
public void checkValueDefinitionExpression() {
Statechart statechart = AbstractTestModelsUtil.loadStatechart(VALIDATION_TESTMODEL_DIR + "ConstWithVariable.sct");
Diagnostic diagnostics = Diagnostician.INSTANCE.validate(statechart);
//
assertIssueCount(diagnostics, 3);
assertError(diagnostics, REFERENCE_TO_VARIABLE);
assertError(diagnostics, CONST_MUST_HAVE_VALUE_MSG);
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class StateBasedRefactoringTest method testRefactoringIsExecutableOnState.
protected void testRefactoringIsExecutableOnState(String pathToInitialSct, String pathToExpectedSct, String stateName, boolean expectedResult) {
Statechart initial = models.loadStatechartFromResource(pathToInitialSct);
State state = getStateByName(initial, stateName);
AbstractRefactoring<?> refactoring = getRefactoring(state);
if (expectedResult) {
Assert.assertTrue("Refactoring on state '" + stateName + "' was not executable, although it should be.", refactoring.isExecutable());
} else {
Assert.assertFalse("Refactoring on state '" + stateName + "' was executable, although it should not be.", refactoring.isExecutable());
}
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class StateBasedRefactoringTest method testRefactoringOnState.
protected void testRefactoringOnState(String pathToInitialSct, String pathToExpectedSct, String stateName) {
Statechart initial = models.loadStatechartFromResource(pathToInitialSct);
State state = getStateByName(initial, stateName);
AbstractRefactoring<?> refactoring = getRefactoring(state);
AbstractSCTResource initialRes = (AbstractSCTResource) initial.eResource();
initialRes.setSerializerEnabled(true);
refactoring.executeRefactoring();
initialRes.setSerializerEnabled(false);
Statechart expected = models.loadStatechartFromResource(pathToExpectedSct);
compareStatecharts(initial, expected);
}
use of org.yakindu.sct.model.sgraph.Statechart in project statecharts by Yakindu.
the class CCodeGeneratorModule method configureEventDriven.
protected void configureEventDriven(GeneratorEntry entry, Binder binder) {
Statechart statechart = (Statechart) entry.getElementRef();
Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
if (eventDrivenAnnotation != null) {
binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
binder.bind(StatemachineSource.class).to(EventDrivenStatemachineSource.class);
binder.bind(CExpressionsGenerator.class).to(EventDrivenExpressionCode.class);
}
}
Aggregations