Permalink
Browse files

Test cases passing... except enter function not being generated for p…

…arallelSm_diffNamesDiffStates_2
  • Loading branch information...
pwang347 committed Oct 9, 2018
1 parent d5c5c91 commit e618a447049a53f989f823703a2819866b648ed1
@@ -84,28 +84,30 @@ class UmpleToJava {
{
// Hierarchically set the default body based on state
MethodBody childDefaultBody = stateMap.getOrDefault(state, defaultBody);
boolean foundChildMethod = false;
if (state.hasNestedStateMachines()) {
boolean shouldPrintCaseStatement = true;
for (StateMachine nestedSm : state.getNestedStateMachines())
{
StringBuilder childBuilder = new StringBuilder();
boolean foundChildMethod = false;
foundChildMethod = traverse(method, nestedSm, state,
StringBuilder childBuilder = new StringBuilder();
boolean result = traverse(method, nestedSm, state,
childDefaultBody, stateMap, childBuilder,
depth + 1) || foundChildMethod;
depth + 1);
if (foundChildMethod)
if (result)
{
foundChildMethod = true;
if (shouldPrintCaseStatement)
{
append(builder, "\n {0} case {1}:", spacing, state.getName());
}
append(builder, childBuilder.toString());
}
}
}
else
if (!foundChildMethod)
{
// Handle leaf nodes
MethodBody body = stateMap.getOrDefault(state, null);
@@ -137,7 +139,5 @@ class UmpleToJava {
{
t.traverse(method);
}
}
#>>
!>>
}#>>!>>
}
@@ -3307,8 +3307,8 @@ private Boolean checkIsDistributed(UmpleInterface uInterface)
// unimplemented methods
if(!uClass.hasMethod(aMethod))
{
//Issue 567
if(shouldAddMethod)
//Issue 567 and 1351
if(shouldAddMethod && !uClass.getStateDependentMethods().contains(aMethod))
uClass.addUnimplementedMethod(aMethod);
}
}
@@ -26,8 +26,8 @@ enum : [~name:key] { [~stateName]? (, [~stateName])* }
state : [=final]? [stateName] { [[stateInternal]]* }
//Issue 547 and 148
stateInternal-# : [[comment]] | [=changeType:+| - |- |*]? [[stateEntity]] | [[standAloneTransition]] |[**extraCode]
stateEntity- : [=-||] | [[mixsetDefinition]] | [[entryOrExitAction]] | [[autoTransition]] | [[transition]] | [[concreteMethodDeclaration]] | [[activity]] | [[state]] | [[trace]] ;
stateInternal-# : [[comment]] | [=changeType:+| - |- |*]? [[stateEntity]] | [[standAloneTransition]] | [[concreteMethodDeclaration]] | [**extraCode]
stateEntity- : [=-||] | [[mixsetDefinition]] | [[entryOrExitAction]] | [[autoTransition]] | [[transition]] | [[activity]] | [[state]] | [[trace]] | ;
autoTransition : [[activity]]? [[autoTransitionBlock]]
@@ -1325,6 +1325,7 @@ public void constraintComparisonWithConstant()
String actual = model.getGeneratedCode().get("X");
File generatedFile = new File(pathToInput+"X.java");
generatedFile.delete();
UmpleModel test = model;
File expected = new File(pathToInput + "ConstraintX.java.txt");
SampleFileWriter.assertFileContent(expected, actual,false);
}
@@ -308,13 +308,6 @@ public void nestedStates()
assertUmpleTemplateFor("nestedStates.ump",languagePath + "/nestedStates."+ languagePath +".txt","LightFixture");
}
// Issue #1351
@Test
public void stateDependentMethodDeclaration()
{
assertUmpleTemplateFor("stateDependentMethodDeclaration.ump",languagePath + "/stateDependentMethodDeclaration."+ languagePath +".txt","Portal");
}
@Test
public void nestedStates_exitInnerBeforeOutter()
{
@@ -13,6 +13,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cruise.umple.statemachine.implementation.StateMachineTest;
import cruise.umple.util.SampleFileWriter;
@@ -33,4 +34,11 @@ public void tearDown()
super.tearDown();
SampleFileWriter.destroy(pathToInput + "statemachine/java/example");
}
//Issue #1351
@Test
public void stateDependentMethodDeclaration()
{
assertUmpleTemplateFor("stateDependentMethodDeclaration.ump",languagePath + "/stateDependentMethodDeclaration."+ languagePath +".txt","Portal");
}
}
@@ -4,7 +4,7 @@
package example;
// line 3 "../stateDependentMethodDeclaration.ump"
public abstract class Portal
public class Portal
{
//------------------------
@@ -76,14 +76,15 @@ public abstract class Portal
{
switch(sm)
{
case closed:
return "closed " + arg;
case open:
return "open " + arg;
default:
return arg;
}
}
public boolean open()
{
boolean wasEventProcessed = false;

0 comments on commit e618a44

Please sign in to comment.